Reputation: 4534
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.
Upvotes: 24
Views: 14118
Reputation: 521
Yeah, that bug is pretty annoying. Just relaunch the Xcode and it will work good
Upvotes: 0
Reputation: 986
I got this to work for a table or collection view cell by setting the color first to a system color, then to my custom color in cellForRowAtIndexPath e.g.
myLabel.textColor = .black
myLabel.textColor = UIColor(named: "My custom color")
Upvotes: -1
Reputation: 51
I was trying change programtelly the textcolor of a UILabel in a UITabelViewCell in cellForRowAt. And the label just change the textcolor after being reloaded.
I could change the label textColor in the beggining after change the TEXTCOLOR IN STORYBOARD TO DEFAULT and i change it programatelly.
Upvotes: 2
Reputation: 3293
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.
Upvotes: 61