iOS CAGradientLayer 颜色渐变
1 CAGradientLayer *layer = [CAGradientLayer layer]; 2 layer.startPoint = (CGPoint){0.5f, 0.0f}; 3 layer.endPoint = (CGPoint){0.5f, 1.0f}; 4 layer.colors = @[(id)[UIColor purpleColor].CGColor, 5 (id)[UIColor cyanColor].CGColor, 6 (id)[UIColor magentaColor].CGColor, 7 (id)[UIColor redColor].CGColor]; 8 layer.locations = @[@0.0f, @0.6f, @1.0f]; 9 layer.frame = self.view.layer.bounds; 10 [self.view.layer insertSublayer:layer atIndex:0];