我不知道这是否与您的外观完全相同(我无法从您的照片中真正看出)。表格底部的单元格逐渐变为黑色。此代码位于 UIViewController 中,并添加了一个表视图作为子视图。表格视图被赋予了蓝色背景色。这在旋转时非常有效。
-(void)viewWillLayoutSubviews {
self.maskGradient.frame = self.view.bounds;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.maskGradient = [CAGradientLayer layer];
self.maskGradient.frame = self.view.bounds;
self.maskGradient.colors = @[(id)[[UIColor colorWithRed:0 green:0 blue:0 alpha:1] CGColor],(id)[[UIColor colorWithRed:0 green:0 blue:0 alpha:1] CGColor],(id)[[UIColor colorWithRed:0 green:0 blue:0 alpha:.2] CGColor]];
self.maskGradient.locations = @[@0.0f,@0.9f,@1.00f];
self.view.layer.mask = self.maskGradient;
// other code to populate the table
[self.tableView reloadData];
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor clearColor];
}