美文网首页
颜色渐变

颜色渐变

作者: 西西西瓜sama | 来源:发表于2016-12-30 11:02 被阅读19次

    颜色透明渐变效果

        CAGradientLayer *colorLayer = [CAGradientLayer layer];
        colorLayer.frame = CGRectMake(0, 0, gradientView.frame.size.width, gradientView.frame.size.height);
        [gradientView.layer addSublayer:colorLayer];
        
        //添加渐变的颜色组合
        colorLayer.colors = [NSArray arrayWithObjects:
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.0] CGColor],
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.1] CGColor],
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.2] CGColor],
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.3] CGColor],
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.4] CGColor],
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.5] CGColor],
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.6] CGColor],
                             (id)[[[UIColor clearColor] colorWithAlphaComponent:.7] CGColor],
                            nil];
    
    

    参考链接:
    UIView 的渐变色呈现
    CAGradientLayer的一些属性解析

    相关文章

      网友评论

          本文标题:颜色渐变

          本文链接:https://www.haomeiwen.com/subject/fnkmvttx.html