The font color for UILabel does not change

I am trying to display numbers on UILabel with bold black font and size 50.

After some unsuccessful attempts, I realized that no matter what color I set with the font, it always gets a lightGray value. Is there anything else I need to do other than below?

[DisplayLabel setFont:[UIFont fontWithName:[NSString stringWithUTF8String:"HelveticaNeue-Bold"] size:50]]; DisplayLabel.textColor = [UIColor brownColor]; DisplayLabel.textAlignment = NSTextAlignmentCenter; 

I add a shortcut using the storyboard to the view.

+13
source share
3 answers

Make sure the behavior of your shortcut is similar. enter image description here

+15
source

I ran into the same problem, but that was the reason by setting my own color in the storyboard. Apparently, you should have the default color attribute set in order to change it programmatically. I found this to be true with all UIView .

+33
source

I tried to programmatically change the text color of a UILabel in a UITabelViewCell in cellForRowAt. And the label just changes the color of the text after a reboot.

I could change the textColor label at the beginning after changing TEXTCOLOR from STORYBOARD to DEFAULT, and I changed it programmatically.

-1
source

Source: https://habr.com/ru/post/973950/


All Articles