<分区>
<分区>
如何在按下按钮时改变按钮的背景颜色?
@property (weak, nonatomic) IBOutlet UIButton *buttonDeleteOutlet;
我的按钮没有方法:setBackgroundColor (UIColor *) forState:(UIControlState *)。仅setBackgroundColor:(UIColor *)。
No visible @interface for 'UIButton' declares the selector 'setBackgroundColor:forState:'
为什么?
最佳答案
你也可以试试这个
(a) I think there is no method like setBackgroundColor: forState: in iOS 6 or iOS 7. So you have to put background color images using below methods
[btn setBackgroundImage:[UIImage imageNamed:@"yourRedButton.png"] forState:UIControlStateHighlighted];
[btn setBackgroundImage:[UIImage imageNamed:@"yourBlueButton.png"] forState:UIControlStateNormal];
(b) Using Tint Color
[YourButton setTintColor:[UIColor color]];
关于ios - 如何更改按钮的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20097101/