我按照下面的教程使用CAGradientLayer在UITableViewCell中制作渐变背景.
http://cocoawithlove.com/2009/08/adding-shadow-effects-to-uitableview.html
除了本教程,本主题还有其他资源吗?
谢谢.
Sus*_*cob 40
总是很棒的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;
}
Run Code Online (Sandbox Code Playgroud)
你可以改变颜色,但这会给你一个好主意......
祝好运!
| 归档时间: |
|
| 查看次数: |
24793 次 |
| 最近记录: |