【发布时间】:2010-11-15 18:02:52
【问题描述】:
可能重复:
UITableViewCell with custom gradient background, with another gradient as highlight color
嘿,我正在尝试使用渐变作为我的 tableView 单元格的背景,我已经尝试使用此代码:
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
[view.layer insertSublayer:gradient atIndex:0];
[cell setBackgroundView:view];
知道为什么这不能正常工作吗?
【问题讨论】:
-
为什么同一个问题会在 12 小时内出现?
-
AppKit 只存在于 Cocoa 中。您正在使用 UIKit。另外,请描述它究竟是如何“无法正常工作”的。
-
vikingosegundo:标题相同,但问题不同,更具体。
-
它不能正常工作的原因在于它不只是显示。
-
好的,所以我看到它在我实际选择单元格并移动到下一个视图时显示了一会儿。它以某种方式显示在选定的状态。
标签: cocoa-touch ios uikit core-graphics quartz-graphics