我创建了一个按钮,我希望在用户点击时更改其颜色.我看到了选项"setimagebackground ... forstate ......",但没有其他选项可以改变背景颜色.我在viewdidload中更改了y按钮的值,当我使用"settint color:[uicolor redcolor]"时,没有任何反应.我该怎么解决?这是我的代码:
button1.layer.borderColor = [[UIColor purpleColor]CGColor];
button1.layer.cornerRadius = 8.0f;
button1.layer.masksToBounds = YES;
button1.layer.borderWidth = 1.0f;
[button1.tintColor = [UIColor redColor]CGColor];
[button1 setTintColor:[UIColor blueColor]];
[button1 setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
[button1 setTintColor:[UIColor redColor]];
Run Code Online (Sandbox Code Playgroud)
谢谢!