Reputation: 55
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. Is unacessible the Backgroundcolor property? I don't recived any error when I Build and Debug, but don't works.
Thanks!
Upvotes: 2
Views: 24318
Reputation: 381
Try This.
- (IBAction)Click:(UIButton *)sender
{
if (sender.selected)
{
sender.selected = NO;
sender.backgroundColor=[UIColor whiteColor];
}
else
{
sender.selected = YES;
sender.backgroundColor=[UIColor blueColor];
}
}
Upvotes: 1
Reputation: 55
Well, finally, I opted for change image button from a colored image, because unfortunately, at the moment, this is impossible for me.
Upvotes: 1
Reputation: 16543
Try this
- (IBAction)OrBoton:(id)sender
{
UIButton *button = (UIButton *)sender;
[button setBackgroundColor:[UIColor redColor]];
}
Upvotes: 5