// 添加tableViewBG_View到self.view上
UIView *tableViewBG_View = [[UIView alloc] initWithFrame:tableViewBGRect];
[self.view addSubview:tableViewBG_View];
// tableView添加到tableViewBG_View上
UITableView *tableView = [[UITableView alloc] initWithFrame:tableViewBG_View.bounds style:UITableViewStylePlain];
[tableViewBG_View addSubview:tableView];
tableView.backgroundColor = [UIColor clearColor];
// 设置顶部渐隐层
CAGradientLayer *gradientLayer = [[CAGradientLayer alloc] init];
gradientLayer = [CAGradientLayer layer];
gradientLayer.startPoint = CGPointMake(0, 0); //渐变色起始位置
gradientLayer.endPoint = CGPointMake(0, 0.1); //渐变色终止位置
gradientLayer.colors = @[(__bridge id)[UIColor.clearColor colorWithAlphaComponent:0].CGColor, (__bridge id)
[UIColor.clearColor colorWithAlphaComponent:1.0].CGColor];
gradientLayer.locations = @[@(0), @(1.0)]; // 对应colors的alpha值
gradientLayer.frame = tableViewBG_View.bounds;
tableViewBG_View.layer.mask = gradientLayer;
iOS 聊天内容滚动渐隐效果
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 这几天改需求,要求将 UIWebView 嵌套在 UIScrollView 里,由 UISCrollView 控制...
- ios的回弹效果,如果下方有一个按钮,上方是滚动区域,当数据比较多时,会显示不全,因为margin-bottom对...
- 实现效果 看到这个效果,看到很多人用ViewFlipper实现,但是效果并不理想,于是我想到用RecyclerVi...
- 今天青石的票圈出镜率最高的,莫过于张艺谋的新片终于定档了。 一张满溢着水墨风的海报一次次的出现在票圈里,也就是老谋...