美文网首页
iOS UIButton颜色渐变 titleLabel字体不显示

iOS UIButton颜色渐变 titleLabel字体不显示

作者: 倒着游的鱼 | 来源:发表于2020-12-03 09:36 被阅读0次
//渐变颜色
        CAGradientLayer *_gradientLayer = [CAGradientLayer layer];
        _gradientLayer.colors = @[(__bridge id)[UIColor colorWithRed:255/255.0 green:157/255.0 blue:72/255.0 alpha:1.0].CGColor, (__bridge id)[UIColor colorWithRed:253/255.0 green:93/255.0 blue:59/255.0 alpha:1.0].CGColor];
        _gradientLayer.startPoint = CGPointMake(0.5, 0);
        _gradientLayer.endPoint = CGPointMake(0.5, 1);
        _gradientLayer.frame = addBtn.bounds;
        _gradientLayer.cornerRadius = 22;
        [addBtn.layer insertSublayer:_gradientLayer atIndex:0];//注意添加顺序 

相关文章

网友评论

      本文标题:iOS UIButton颜色渐变 titleLabel字体不显示

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