CAGradientLayer *gradientLayer = [[CAGradientLayer alloc] init];
gradientLayer.colors = @[(__bridge id)mRGBToColor(0xff8800).CGColor,(__bridge id)mRGBToColor(0xff5100).CGColor];
//位置x,y 自己根据需求进行设置 使其从不同位置进行渐变
gradientLayer.startPoint = CGPointMake(1, 0);
gradientLayer.endPoint = CGPointMake(1, 1);
gradientLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.backView.frame), CGRectGetHeight(self.backView.frame));
[self.backView.layer addSublayer:gradientLayer];
时间: 2024-11-05 02:25:41