I am creating an iPhone application in which i have a custom button. i have set the buttons title by creating a Label and adding it as subview. now when the button is highli
Found the answer in a different question on StackOverflow: UIButton color issues
[button1 setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
This is if you can work without creating a Label and adding it as subview as you mention above.
For SelectedColor
[yourButton setTitleColor:[UIColor purpleColor] forState:UIControlStateSelected];
For HighlightedColor
[yourButton setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
you can add target for UIControlStateHighlighted
state of UIButton
like
[button1 addTarget:self action:@selector(buttonHighlighted:) forControlEvents:UIControlStateHighlighted];
and in buttonHighlighted
method you can change the color of your label's text
- (void) buttonHighlighted:(id)sender
{
//code here
}
Hope it gives you an idea.