美文网首页
改变button上图片的颜色

改变button上图片的颜色

作者: 哎呦我去叫什么呢 | 来源:发表于2017-04-13 10:36 被阅读269次

    UIImage *buttonImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:str]]];
    _button.tintColor = UIColorFromRGB(0x52b0da);//设置新的颜色
    //取消图片原来的颜色
    [_button setImage:[buttonImage imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)] forState:(UIControlStateNormal)];

    UIButton *button = [UIButton alloc] initWithFrame:CGRect(100, 100, 100 , 100)];
    //设置边框颜色
    button.layer.borderColor = [[UIColor redColor] CGColor];
    //设置边框宽度
    button.layer.borderWidth = 1.0f;
    //给按钮设置角的弧度
    button.layer.cornerRadius = 4.0f;
    //设置背景颜色
    button.backgroundColor = [UIColor redColor];
    button.layer.masksToBounds = YES;

    作者:代码干货
    链接:http://www.jianshu.com/p/0cfd3c9b90f6
    來源:简书
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

    相关文章

      网友评论

          本文标题:改变button上图片的颜色

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