如何更改 TapkuLibrary 日历对象上的事件标记

发布于 2024-11-28 00:22:00 字数 272 浏览 5 评论 0原文

我的日历使用 TapkuLibrary。我想更改事件标记,例如在该月的某些日子显示不同的操作。我想要实现类似第二张图片的效果。

默认 TapkuLibrary 日历

Default TapkuLibrary calendar

我想要喜欢这样的东西

我想要这样的东西

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

Default TapkuLibrary calendar

I want to like something like this

I want to like something like this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回心转意 2024-12-05 00:22:00

注意:我首先要解释 Tapku 当前如何绘制其 MonthView 标记,然后我将提出一种更改它的方法。

Tapku 实际上并没有将这些标记设置为图像;而是将这些标记设置为图像。它将它们设置为字符串!在 TKCalendarMonthView 中搜索 •。标记在 TKCalendarMonthView 中的两个不同位置设置:首先,在 drawTileInRect:day:mark:font... 方法中,该方法在 drawRect 方法中在每个图块上单独调用。其次,属性“点”应用于用户“选定”的单元格,该单元格具有不同的文本颜色等,因此需要调整其自己的属性。

要设置您自己的图像,您必须在这两个地方修改 Tapku(不是非常困难;这是一个非常容易访问的项目)。因此,您不必将单元格的文本设置为•,而是必须将其图像设置为您提供的图像。

可以通过几种不同的方式提供此图像。最直接的方法是重做 Tapku 的“marks”数组概念(由委托设置)。也许您可以创建 UIImage 数组,而不是创建整数数组。尽管如此,您仍然需要有一种方法来告诉代码“无图像”——也许有一个空白图像,然后默认将其应用到单元格?

如果您需要任何说明,请告诉我。

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.

花辞树 2024-12-05 00:22:00

使用下面的方法而不是 - DrawTileInRect
一个月内有多种颜色,请检查日期

- (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);

    }
}

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);

    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文