ios 渐变背景颜色

#define RGBA(r,g,b,a)       [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define MainColor1                 RGBA(72, 137, 219,  0.8)//主题橘色1
#define MainColor2                 RGBA(173, 147, 253,  0.8)//主题橘色2

 //渐变颜色
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.colors     = @[(__bridge id)MainColor1.CGColor, (__bridge id)MainColor2.CGColor];
    gradientLayer.locations  = @[@0.3, @1.0];
    gradientLayer.startPoint = CGPointMake(0, 0);
    gradientLayer.endPoint   = CGPointMake(1.0, 0);
    gradientLayer.frame      = CGRectMake(0, 0,  SCREEN_WIDTH-50, 40);
    [self.AddShip.layer addSublayer:gradientLayer];



你可能感兴趣的:(移动)