I am trying to display numbers on a UILabel with a bold black font and size 50.
After some failed attempts I just realized that no matter what color I set the font to, it always gets set to lightGray. Is there something else I need to do other than the below?
[DisplayLabel setFont:[UIFont fontWithName:[NSString stringWithUTF8String:"HelveticaNeue-Bold"] size:50]]; DisplayLabel.textColor = [UIColor brownColor]; DisplayLabel.textAlignment = NSTextAlignmentCenter;
I am adding the label using the storyboard to a view.
The easiest workaround is create dummy labels in IB, give them the text the color you like and set to hidden. You can then reference this color in your code to set your label to the desired color. The only way I could change the text color programmatically was by using the standard colors, UIColor.
Write the following text in the label “Bold Regular”Double Click on Bold to select it, and then right click on it to see more options. Select font > Bold from that option. It should do the task.
To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.
I encountered the same issue but it was cause by setting a custom color in the storyboard. Apparently you must have the color attribute set to default
in order to change it programatically. I found this true with all UIView
s.
Make sure your label's behavior like that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With