我尝试使用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];
}
答案 0 :(得分:3)
是的,这项技术将提高直接IB细胞的性能。但是如果你让单元格的所有元素都不透明,那么IB的表现可能会相当不错 - 你可能想先尝试一下,然后再沿着大量代码的路径去创建简单的单元格。