更改Tapku日历上标记日期的所选图像

时间:2011-11-23 13:01:26

标签: objective-c ios

嗨,我已经浏览了网络和许多博客但似乎没有关于如何更改tapku日历控件的标记日期的图像的信息。我已经对代码做了一些研究,但无法完成目标。

现在写我能够改变日期瓦片的backgournd图像。但是当我这样做时,日期的文字已经消失了吗?

我更改了方法

TKmonthView.m文件的图像
- (void) drawTileInRect:(CGRect)r day:(int)day mark:(BOOL)mark font:(UIFont*)f1 font2:(UIFont*)f2 method 

我需要一些帮助这是我的代码

    if(mark){
    r.origin.y-=5;
    [[UIImage imageWithContentsOfFile:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/Month Calendar Date Tile Gray.png")] drawInRect:r];

    r.size.height = 10;
    r.origin.y += 18;

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

看起来没有人想谈论它。但我想我已经找到了解决方案。我的应用程序的运行代码看起来像这样。它只需要一些测试,也可以选择标记日期我需要一些解决方案我会调查一下。我的解决方案正在关注

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

if (mark) {
    r.origin.y-=6.5;
    [[UIImage imageWithContentsOfFile:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/Month Calendar Date Tile Gray.png")] drawInRect:r];
    r.origin.y+=6.5;
}

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


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

if(mark){
    r.origin.y-=6;
//      self.selectedImageView=[UIImage imageWithContentsOfFile:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/Month Calendar Date Tile Gray.png")];
    r.origin.y +=6;
    r.size.height = 10;
    r.origin.y += 18;

    [@"•" drawInRect: r
            withFont: f2
       lineBreakMode: UILineBreakModeWordWrap 
           alignment: UITextAlignmentCenter];

}


}

1 个答案:

答案 0 :(得分:0)

图片位于:TapkuLibrary.bundle/Images/calendar/Month Calendar Today,或者您可以将路径指向您自己的图片。

self.selectedImageView.image = [UIImage imageWithContentsOfFile:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/Month Calendar Today Selected Tile.png")]; 

//您可以使用自己的图片

 UIImage *tile = [UIImage imageWithContentsOfFile:TKBUNDLE(@"yourImage.png")];