zoukankan      html  css  js  c++  java
  • iOS开发UI篇——Core Animation核心动画CAGradientLayer(实现渐变色等)简介

    一、CAGradientLayer实现渐变色(设置tableView背景为渐变色)

    [self.view setBackgroundColor:[UIColor whiteColor]];
    UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0,0, mainWidth, mainHeight-64)];
    table.separatorStyle = UITableViewCellSeparatorStyleNone;
    //当设置layer渐变色时,一定要把view的颜色设置为透明,要不会被覆盖
    [table setBackgroundColor:[UIColor clearColor]];
    //设置颜色值 
    UIColor *_inputColor0 = [UIColor redColor];
    UIColor *_inputColor1 = [UIColor orangeColor];
    //1.创建layer
    CAGradientLayer *redLayer2 = [CAGradientLayer new];
    //2.可以添加多种颜色,这里只设置两种颜色
     redLayer2.colors = @[(__bridge id)_inputColor1.CGColor, (__bridge id)_inputColor0.CGColor];
    //3.设置渐变颜色方向,左上点为(0,0), 右下点为(0,1)
    redLayer2.startPoint = CGPointMake(0, 0);
    redLayer2.endPoint = CGPointMake(0, 1);
    redLayer2.frame = self.secondTable.frame;
    //4.将layer添加到视图上
    [self.view.layer addSublayer:redLayer2];
    [self.view addSubview:table];
  • 相关阅读:
    office2007快捷键
    To be solved
    网址Favorites
    C#网址
    developer's website
    Visual Studio快捷键
    如何跟进大客户?
    这些话让我们意识到流程的重要性
    恭祝大家情人节快乐!
    知已知彼,大客户管理10策
  • 原文地址:https://www.cnblogs.com/TheYouth/p/7007138.html
Copyright © 2011-2022 走看看