I have a UILabel in my ViewController created using storyboards. The font, size and color of the label's text, its alignment - all set in the storyboard. The label in the storyboard is connected to the outlet in my file called p_patientNameLbl.
Now I am trying to change the text of the label programatically, like this:
[self.p_patientNameLbl setText:@"Vasya"];
I could not see the new text, until I realized that the original label in the storyboard was white on black background, but apparently after I changed the label's text as above, all the font attributes have been reset and now it was a black text on black background, and therefore not seen. Once I set the color programmatically:
[self.p_patientNameLbl setTextColor:[UIColor whiteColor]];
I could see the new label, but all the rest of the font attributes and alignment were still wrong.
Is there a way to change only the text of the label without having then programmatically to set all the rest of the attributes? I would imagine there must be a way, since I don't want to be formatting my interface in the code!
setText:
shouldn't change your UILabel's color. If you NSLogself.p_patientNameLbl.textColor
before and after yousetText:
, what does the log tell you? – Spout