I know this might have been asked before but, I've been trying to find an answer to this for ages. I am new to Xcode and would like to know, how do you change a buttons background colour when it is tapped?
Thanks
I know this might have been asked before but, I've been trying to find an answer to this for ages. I am new to Xcode and would like to know, how do you change a buttons background colour when it is tapped?
Thanks
Below code will change your button's background color to a blackColor.. You can change to whatever color you desire
- (IBAction)buttonClicked:(id)sender {
yourButton.backgroundColor = [UIColor blackColor];
}
You can call setBackgroundColor: in method which fired when button pressed:
- (IBAction)buttonPressed:(id)sender
{
UIButton *btn = (UIButton*)sender;
[btn setBackgroundColor:[UIColor redColor]];
}