我按照下面的教程使用 CAGradientLayer 在 UITableViewCell 中制作渐变背景。
http://cocoawithlove.com/2009/08/adding-shadow-effects-to-uitableview.html
除了本教程之外,该主题还有其他资源吗?
Thanks.
一直很棒的 Ray Wenderlich 做了一个关于更改 UITableViewCells 的教程,其中包括渐变。
http://www.raywenderlich.com/2033/core-graphics-101-lines-rectangles-and-gradients
如果你想要一个快速的方法,这里有一些代码:
//include #import <QuartzCore/QuartzCore.h> in the header…
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (cell == nil) {
cell = [[DayCalendarCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = cell.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor]CGColor], (id)[[UIColor redColor]CGColor], nil];
[cell.layer addSublayer:gradient];
}
return cell;
}
你可以改变颜色,但这会给你一个好主意......
祝你好运!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)