I have the following code in a viewController, all the outlets and action are hooked up correctly. the WHITE
and PURPLE
are UIColors that I've defined constants for. I've also set the UIWindow
's tintColor
to PURPLE
and that propagates down to the button.
- (void)viewDidLoad {
[super viewDidLoad];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
button.backgroundColor = WHITE;
button.layer.borderWidth = 1.0;
button.layer.masksToBounds = YES;
button.layer.cornerRadius = 5.0;
button.layer.borderColor = PURPLE.CGColor;
}
-(IBAction) buttonTouchDown:(id)sender {
button.backgroundColor = PURPLE;
button.layer.borderColor = WHITE.CGColor;
}
-(IBAction) buttonTouchUpOutside:(id)sender {
button.backgroundColor = WHITE;
button.layer.borderColor = PURPLE.CGColor;
}
-(IBAction) buttonTouchUpInside:(id)sender {
button.backgroundColor = WHITE;
button.layer.borderColor = PURPLE.CGColor;
}
When I click the button the text doesn't go white like i told it to in viewDidLoad
here's some screenshots that I could've cropped better!
As you can see in the highlighted state it's not white but like a white and purple mix.
Will I need to use UIButtonTypeCustom
? I heard if I do that I won't get the advantages of iOS 7 doing its magic with tintColor
. Not sure what's the correct way to go about this. Thanks in advance.