一般我们创建UIButton的时候都是
1. [[UIButton alloc] init];
2. [UIButton new];
这两种创建方法.
比如设计给我们的是一张绿色的图.我们某个页面需要弄成白色的话.又得UI重新设计一下图片给我们.挺麻烦的.
查阅文档发现.上面的两种创建方法等同于
[UIButton buttonWithType:UIButtonTypeCustom];
1. 图片tintColor第一种方式.
UIButtonType里头有个UIButtonTypeSystem我们把创建方式改成[UIButton buttonWithType:UIButtonTypeSystem];
然后修改UIButton的tintColor.就可以改变图片的颜色了.
2.图片tintColor的第二种方式.
或者是不设置UIButton的ButtonType.设置[[UIImage imageNamed:@“xxx”] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]