HelloWorld HelloWorld - 2 years ago 198
Swift Question

How can I change UIButton title color?

I create a button programmatically

button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[view addSubview:button];

how can I change title color?

Answer Source

You can use -[UIButton setTitleColor:forState:] to do this.


buttonName setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

Thanks to richardchildan

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download