实现效果如下:

UITableView实现行纵向颜色渐变

其实实现很简单,开始觉得使用颜色值和tableView的indexPath.row挂钩使用即可

或者使用CAGradientLayer实现渐变

最后使用alpha实现即可。需要注意的是alpha的值大小和行数(或者section值相反)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    ColorGradientCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ColorGradientCell" forIndexPath:indexPath];
    cell.titileLabel.font = [UIFont systemFontOfSize:15];
    cell.titileLabel.text = @"思思";
    cell.tipLabel.text = [NSString stringWithFormat:@"%ld", indexPath.section + 1];
    // 透明度来实现渐变
    cell.tipLabel.alpha = (tableView.numberOfSections - indexPath.section) * 0.2;
    return cell;
}

有更好的实现方式可以留言告知哟。。。

相关文章:

  • 2022-03-01
  • 2022-02-27
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-12-05
猜你喜欢
  • 2021-12-04
  • 2022-12-23
  • 2021-05-06
  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
相关资源
相似解决方案