I am using TdCalendarView code by Tinyfool in my project in which all calendar is designed using core graphics.I want to color rows of this calendar with tw开发者_Go百科o alternate colors.How can I do that?
You need to change the stroke fill color here for either even value of i in for loop or odd value
-(void)drawDateWords
{
CGContextRef ctx=UIGraphicsGetCurrentContext();
int width=self.frame.size.width;
int dayCount=[self getDayCountOfaMonth:currentMonthDate];
int day=0;
int x=0;
int y=0;
int s_width=width/7;
int curr_Weekday=[self getMonthWeekday:currentMonthDate];
// Normaly big Font
[array_Date addObject:@""];
[array_Month addObject:@""];
[array_Year addObject:@""];
[array_Desc addObject:@""];
[array_LastDate addObject:@""];
[self.array_Name addObject:@""];
UIFont *weekfont=[UIFont boldSystemFontOfSize:20];
for(int i=1;i<dayCount+1;i++)
{
day=i+curr_Weekday-2;
x=day % 7;
y=day / 7;
NSString *date=[[[NSString alloc] initWithFormat:@"%d",i] autorelease];
for (int j=0; j<[array_Date count]; j++) {
NSString *date1 = [array_Date objectAtIndex:j];
int month1 = [[array_Month objectAtIndex:j] intValue];
int year1 = [[array_Year objectAtIndex:j] intValue];
if ([date isEqualToString:date1] && currentMonthDate.month == month1 && currentMonthDate.year == year1)
{
//[@"*" drawAtPoint:CGPointMake(x*s_width+18,y*itemHeight+headHeight+18) withFont:[UIFont boldSystemFontOfSize:25]];
//[date drawAtPoint:CGPointMake(x*s_width+18,y*itemHeight+headHeight+18) withFont:[UIFont boldSystemFontOfSize:25]];
[[UIColor redColor] set];
}
else{
//[[UIColor redColor] set];
[date drawAtPoint:CGPointMake(x*s_width+15,y*itemHeight+headHeight) withFont:weekfont];
}
}
if([self getDayFlag:i]==1)
{
CGContextSetRGBFillColor(ctx, 1, 0, 0, 1);
[@"." drawAtPoint:CGPointMake(x*s_width+19,y*itemHeight+headHeight+6) withFont:[UIFont boldSystemFontOfSize:25]];
}
else if([self getDayFlag:i]==-1)
{
CGContextSetRGBFillColor(ctx, 0, 8.5, 0.3, 1);
[@"." drawAtPoint:CGPointMake(x*s_width+19,y*itemHeight+headHeight+6) withFont:[UIFont boldSystemFontOfSize:25]];
}
CGContextSetRGBFillColor(ctx, 0, 0, 0, 1);
}
}
精彩评论