开发者

How can I change the event marks on TapkuLibrary calendar object

I use TapkuLibrary for my calendar. I want to change the event marks, for example to show different operations on certain days of the month. I 开发者_高级运维want to achieve something like the second image.

Default TapkuLibrary calendar

How can I change the event marks on TapkuLibrary calendar object

I want to like something like this

How can I change the event marks on TapkuLibrary calendar object


N.B. I'm first going to explain how Tapku currently draws its MonthView marks, and then I'll propose a way to change it.

Tapku doesn't actually set those marks as images; it sets them as strings! Search TKCalendarMonthView for •. The marks are set in two different places in TKCalendarMonthView: First, in the drawTileInRect:day:mark:font... method, which is called on each tile individually in the drawRect method. Second, with the property 'dot', which is applied to the user's 'selected' cell, which has a different text color, etc. and thus needs to have its own properties adjusted.

To set your own images, you'll have to modify Tapku in those two places (not terribly difficult; it's a pretty accessible project). So, instead of setting the cell's text to •, you'll have to set its image to an image you provide.

Providing this image could be done in a few different ways. The most straightforward will be to redo Tapku's concept of the 'marks' array (set by the delegate). Instead of creating an array of integers, perhaps you could create an array of UIImages. Still, you need to have a way to tell the code "no image"--maybe have a blank image and just apply it to cells by default?

Let me know if you need any clarification.


use bellow method instead of - DrawTileInRect for multiple color in one month , check date

- (void) drawTileInRect:(CGRect)r day:(int)day mark:(BOOL)mark font:(UIFont*)f1 font2:(UIFont*)f2 sysFlag:(int)sysFlg userEventFlg:(int)userEventFlag diaryFlg:(int)diaryFlag momentsFlg:(int)momentsFlag
{
   
    @try {
        
        NSString *str = [NSString stringWithFormat:@"%d",day];
        [str retain];
        
        
        r.size.height -= 2;
        [str drawInRect: r
               withFont: f1
          lineBreakMode: UILineBreakModeWordWrap
              alignment: UITextAlignmentCenter];
        
        r.size.height = 10;
        r.origin.y += 18;
        
        CGRect y=CGRectMake(r.origin.x+5, r.origin.y-25, 12, 12);//5 5
        
        
        CGRect rect1=CGRectMake(r.origin.x, r.origin.y+7, 12, 12);
        CGRect rect2=CGRectMake(rect1.origin.x+18, r.origin.y+7, 12, 12);
        CGRect rect3=CGRectMake(rect2.origin.x+16, r.origin.y+7, 12, 12);
        
        if(sysFlg==1)
        {
            [[UIImage imageNamed:@"Blue_dot.png"] drawInRect:y];
        }
        
        if(userEventFlag==1)//1.png
        {
            [[UIImage imageNamed:@"Yellow_dot.png"] drawInRect:rect1];
        }
        
        
        if(momentsFlag==1)//3.png
        {
            [[UIImage imageNamed:@"Red_dot.png"] drawInRect:rect3];
        }
        

    }
    @catch (NSException * e) {
        NSLog(@"Exception: %@", e);

    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜