美文网首页
UILabel 背景添加渐变,文字消失的处理方法

UILabel 背景添加渐变,文字消失的处理方法

作者: 未来可期me | 来源:发表于2020-04-09 12:56 被阅读0次

'''
/// 给view的背景添加渐变色

  • (void)setViewBackColors:(UIColor *)startColor endColor:(UIColor *)endColor andLocations:(NSArray *)locations{
    //渐变颜色
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.colors = @[(__bridge id)startColor.CGColor, (__bridge id)endColor.CGColor];
    gradientLayer.locations = locations;
    gradientLayer.startPoint = CGPointMake(0, 0);
    gradientLayer.endPoint = CGPointMake(1.0, 1.0);
    gradientLayer.frame = self.bounds;
    gradientLayer.cornerRadius = self.layer.cornerRadius;
    [self.layer insertSublayer:gradientLayer atIndex:-1];
    }

'''

但是 对于UILabel设置背景完全没用啊,uibutton又不能改,终于知道了这个办法

‘’‘
UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_norvip_price_frog"]];
[self setBackgroundColor:color];
’‘’

相关文章

网友评论

      本文标题:UILabel 背景添加渐变,文字消失的处理方法

      本文链接:https://www.haomeiwen.com/subject/yztcmhtx.html