Xcode – How to change the titleLabel font color, Xcode

labeluibuttonuicolorxcode

This code seems to work well, modifying the properties of my button, except the titleLabel font color is not changing. I can change the font, font size, shadow but not the color. It currently displays as white although I am trying to set it to black. I've tried button1.titleLabel.textColor = [UIColor blackColor]; and [button1.titleLabel setTextColor:[UIColor blackColor]]; seems to recognize the property but still remains white.

[button1.titleLabel setTextColor:[UIColor blackColor]];        
[button1.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];
[button1.titleLabel setShadowColor:[UIColor blackColor]];
[button1.titleLabel setShadowOffset:CGSizeMake(-1, 1)];
[button1 setTitle:@"Do it" forState:UIControlStateNormal];
button1.frame = CGRectMake(0, 0, 250, 40.0);
[myView addSubview:button1];

Best Answer

This worked.

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