阅读背景:

IOS-UITableViewCell的渐变色

来源:互联网 
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { [cell setBackgroundColor:[UIColor clearColor]]; CAGradientLayer *grad = [CAGradientLayer layer]; grad.frame = cell.bounds; grad.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:52.0f/255.0f green:50.0f/255.0f blue:51.0f/255.0f alpha:1.0f] CGColor], (id)[[UIColor colorWithRed:35.0f/255.0f green:34.0f/255.0f blue:34.0f/255.0f alpha:1.0f] CGColor], nil]; [cell setBackgroundView:[[UIView alloc] init]]; [cell.backgroundView.layer insertSublayer:grad atIndex:0]; CAGradientLayer *selectedGrad = [CAGradientLayer layer]; selectedGrad.frame = cell.bounds; selectedGrad.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil]; [cell setSelectedBackgroundView:[[UIView alloc] init]]; [cell.selectedBackgroundView.layer insertSublayer:selectedGrad atIndex:0]; } -(void)tableView:(UITableView *)tableView willD



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: