开发者

Done marking dates in tapku library in single background color want three colors Objective C

I am using tapku library for displaying calender in my application. I have done all date calculations and marked the cells properly acccording to my need but I want to give a different color to the cell according to my choice. I have done marking in single background color but I want t开发者_如何学Goo display in three colors. How can I?


Look at the method:

The color is set to [UIColor grayColor] in the drawRect: method (one below in the code). What you can do is check if the date is a date you're interested in and then change the color appropriately. I'm not sure how you want to differentiate between your dates--it's your call; in the past, I've changed the parameter of the mark argument to something like an int and then basing the color on the int's value. The mark argument comes from the marks array, so if you pass in an array with different values and then change the method arguments throughout the TKCalendarMonthView, it should be okay.

For example, lets say you want: mark = 1 --> draw red; mark = 2 --> draw green; mark > 2 --> draw blue.

- (void) drawTileInRect:(CGRect)r day:(int)day mark:(**int**)mark font:(UIFont*)f1 font2:(UIFont*)f2
{

    NSString *str = [NSString stringWithFormat:@"%d",day];


    r.size.height -= 2;
    [str drawInRect: r
       withFont: f1
      lineBreakMode: UILineBreakModeWordWrap 
      alignment: UITextAlignmentCenter];

    if (mark) {
        if (mark == 1)
             [[UIColor redColor] set];
        else if (mark == 2)
             [[UIColor greenColor] set];
        else if (mark > 2)
             [[UIColor blueColor] set];
        r.size.height = 10;
        r.origin.y += 18;

        [@"•" drawInRect: r
                withFont: f2
           lineBreakMode: UILineBreakModeWordWrap 
           alignment: UITextAlignmentCenter];
     }
   [[UIColor grayColor] set];

}

Hope this answers your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜