在我的应用程序中,我使用CAGradientLayer设置我的单元格的背景,这样:
retValue = [tableView dequeueReusableCellWithIdentifier:@"Cells" forIndexPath:indexPath]; UIView *bgColorView = [[UIView alloc] init]; bgColorView.backgroundColor = [UIColor blueColor]; bgColorView.layer.masksToBounds = YES; id startColor = (id)[[UIColor colorWithWhite:0.75 alpha:1] CGColor]; id endColor = (id)[[UIColor blueColor] CGColor]; CAGradientLayer* gradientLayer = [CAGradientLayer layer]; gradientLayer.frame = retValue.contentView.bounds; gradientLayer.colors = @[startColor,startColor,endColor,endColor]; gradientLayer.locations = @[[NSNumber numberWithFloat:0],[NSNumber numberWithFloat:0.95],[NSNumber numberWithFloat:1]]; [gradientLayer setStartPoint:CGPointMake(0,0.5)]; [gradientLayer setEndPoint:CGPointMake(1,0.5)]; [bgColorView.layer addSublayer:gradientLayer]; retValue.selectedBackgroundView = bgColorView;
(这段代码在里面 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。