[英]How to set or change button background color on IBAction
I try to set the background color of a button, but, isn't work. 我尝试设置按钮的背景色,但是不起作用。 Some can helpme please? 有些可以帮我吗?
- (IBAction)OrBoton:(id)sender {
[sender setBackgroundColor:(NSColor *)redColor];
}
But, if I try to setTitle, this works fine. 但是,如果我尝试设置setTitle,则效果很好。 Is unacessible the Backgroundcolor property? 不需要Backgroundcolor属性吗? I don't recived any error when I Build and Debug, but don't works. 在构建和调试时,我没有收到任何错误,但是没有用。
Thanks! 谢谢!
Try this 尝试这个
- (IBAction)OrBoton:(id)sender
{
UIButton *button = (UIButton *)sender;
[button setBackgroundColor:[UIColor redColor]];
}
Try This. 尝试这个。
- (IBAction)Click:(UIButton *)sender
{
if (sender.selected)
{
sender.selected = NO;
sender.backgroundColor=[UIColor whiteColor];
}
else
{
sender.selected = YES;
sender.backgroundColor=[UIColor blueColor];
}
}
好吧,最后,我选择了从彩色图像更改图像按钮,因为不幸的是,目前,这对我来说是不可能的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.