3
我嘗試使用Tweetie的創建者Loren Brichter的technique(或this technique)創建快速滾動列表。我相信這個想法是「做你自己的繪圖」,而不是在UITableViewCell中使用子視圖和圖像。使用圖像快速滾動表格單元格。這是怎麼完成的?
下面我將他的示例擴展爲包含圖像,我不確定這是否是正確的方法?
我一直在試圖與CALayer玩弄,並努力'得到它'。所以在這個例子中,我只是繪製出一張圖片。但我不確定 - 這與圖像在視圖中的顯示方式相同?接下來,我將使用UIGraphicsBeginImageContext來包含更多圖像(例如footerImage)
在本示例中,我正在做什麼來提高性能而不是在IB中創建它?
感謝
- (void)drawContentView:(CGRect)r
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIColor *backgroundColor = [UIColor whiteColor];
UIColor *textColor = [UIColor blackColor];
if(self.selected)
{
backgroundColor = [UIColor clearColor];
textColor = [UIColor whiteColor];
}
[backgroundColor set];
CGContextFillRect(context, r);
// This is where I add the image to the example
//
CGRect profile = CGRectMake(0, 0, 320, 20);
[headerImage drawInRect:profile];
CGPoint p;
p.x = 12;
p.y = 9;
[textColor set];
CGSize s = [firstText drawAtPoint:p withFont:firstTextFont];
p.x += s.width + 6; // space between words
[lastText drawAtPoint:p withFont:lastTextFont];
}
由於Loren的博客已不在線,因此文章鏈接被中斷。以下指向存檔版本的鏈接。 [用UITableView快速滾動Tweetie](http://web.archive.org/web/20100922230053/http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/) – robotpukeko 2012-07-23 21:33:16
@robotpukeko謝謝,更新。還添加了另一個鏈接... – Ross 2012-07-24 11:32:28