全局设置背景颜色在UIButtons上

时间:2014-01-01 23:17:20

标签: ios objective-c

全局更改所有UIButtons背景颜色的最佳方法是什么?我已经全局设置了色调

[[UIApplication sharedApplication] delegate].window.tintColor =

2 个答案:

答案 0 :(得分:4)

[[UIButton appearance] setBackgroundImage:[UIImage imageNamed:@"button.png"]
                            forState:UIControlStateNormal];

或者

[[UIButton appearance] setBackgroundColor:[UIColor purpleColor]];

以下是有关外观代理的更多信息:http://developer.apple.com/library/ios/documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html

答案 1 :(得分:0)

检查出来:

[[UIButton appearance] setBackgroundColor:[UIColor redColor]];
相关问题