iOS渐变色

1、图片实现
简单、方便、灵活
2、用CAGragidentLayer实现

CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = _containerView.bounds;
[superView.layer addSublayer:gradientLayer];
    
gradientLayer.colors = @[(__bridge id)[UIColor blueColor].CGColor, (__bridge id)[UIColor cyanColor].CGColor, (__bridge id)[UIColor greenColor].CGColor];
gradientLayer.locations = @[@0, @0.5, @1];
    
gradientLayer.startPoint = CGPointMake(0, 0);
gradientLayer.endPoint = CGPointMake(1, 0);

你可能感兴趣的:(iOS渐变色)