【发布时间】:2014-03-25 20:30:16
【问题描述】:
在我的 UITableview 中,我创建了一个渐变层并将其应用于单个单元格。
CAGradientLayer *gradient = [CAGradientLayer layer];
CGRect gradframe = CGRectMake(cell.frame.origin.x, cell.frame.origin.y, self.view.frame.size.width, cell.frame.size.height);
gradient.frame = gradframe;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:.9 green:.9 blue:.9 alpha:1.0] CGColor], (id)[[UIColor colorWithRed:.8 green:.8 blue:.8 alpha:1.0] CGColor], nil];
[cell setBackgroundView:[[UIView alloc] init]];
[cell.backgroundView.layer insertSublayer:gradient atIndex:0] ;
当我在屏幕外滚动并向后滚动单元格时,它们会丢失渐变层。
我对 ios 开发还是有点陌生,如果有任何帮助,我们将不胜感激。
编辑:这只会偶尔发生。偶尔上下滚动时,会有一个包含该图层的单元格。甚至这些单元格也不一致。
【问题讨论】:
-
我猜你的问题出在 cellForRowAtindexPath 中的其他地方。显示更多代码。
-
嗨,你解决了吗?
标签: ios objective-c uitableview gradient