iOS 设置view的颜色渐变

demo 展示

iOS 设置view的颜色渐变_第1张图片
背景颜色view的透明度渐变
        // 设置渐变色
        CAGradientLayer *layer = [CAGradientLayer layer];
        layer.startPoint = CGPointMake(0, 0);
        layer.endPoint = CGPointMake(0, 1);
        layer.colors = @[(__bridge id)CYCOLORA(0x000000, 0).CGColor, (__bridge id)CYCOLORA(0x000000, 1.0).CGColor];
        layer.frame = self.shadeView.layer.bounds;
        [self.shadeView.layer insertSublayer:layer atIndex:0];

你可能感兴趣的:(iOS 设置view的颜色渐变)