iOS TableView 滚动顶部半透明效果
需要在UITableView的父视图添加半透明遮罩
1 2 3 4 5 6 7 8 9 10 11 12 |
// 渐变图层 CAGradientLayer *gradientLayer = [CAGradientLayer layer]; gradientLayer.frame = self.view.frame; // 设置颜色 gradientLayer.colors = @[(id)[[UIColor blackColor] colorWithAlphaComponent:0.0f].CGColor, (id)[[UIColor blackColor] colorWithAlphaComponent:1.0f].CGColor]; gradientLayer.locations = @[ @0, @0.15, @1]; // 添加渐变图层 self.view.layer.mask = gradientLayer; |
Leave a Comment