iOS--创建炫酷的渐变色界面

{

  CAGradientLayer *_layer;
}

 
//创建渐变层
    _layer =[CAGradientLayer layer];
    _layer.frame=self.view.frame;
    
    //设置渐变开始的坐标
    _layer.startPoint=CGPointMake(0.0, 0.4);
    //设置渐变结束的坐标
    _layer.endPoint=CGPointMake(0.0, 1.0);
    //将渐变层添加到视图层上
    [self.view.layer insertSublayer:_layer atIndex:0];
    
    UIColor *color1 =[UIColor colorWithRed:0.427451 green:0.737255 blue:0.643137 alpha:1];
    UIColor *color2 =[UIColor colorWithRed:0.572549 green:0.345098 blue:0.74902 alpha:1];
    //设置渐变层的颜色数组
    _layer.colors=@[(id)[color1 CGColor ],(id)[color2 CGColor]];

 

posted @ 2015-10-18 19:08  WheatDen  阅读(243)  评论(0编辑  收藏  举报