I am using the following code to set the title label’s text color, alignment and font size when adding a ui button in xcode. The font size is picked up but not the text color and alignment, why? Thanks.
toButton.titleLabel.textColor = [UIColor redColor];
toButton.titleLabel.textAlignment = UITextAlignmentRight;
toButton.titleLabel.font = [UIFont boldSystemFontOfSize:FONT_SIZE];
[toButton setTitle:fromButton.titleLabel.text forState:UIControlStateNormal];
You are setting the color to
titleLabelinstead of this, use:For text alignment this line will work:
You can also use: