UILabel automatically changes color

2.2k views Asked by At

i'm facing a really strange problem: i have some UILabel in my view, which has a black background, so i set their text color to white in Interface Builder in order to see them, the problem is, when i run the app on the simulator or on my iphone with ios7 or iOS 6.1.3 i can update them without problems (for update i mean: myLabel.text = @"Something")

but when i run the app on my sister's iphone 3gs with iOS 6.0 at the moment i update them the font color turns black. It seems that on her phone the label can't remember the color set on IB.

Does anyone of you know why this happens? Thanks

3

There are 3 answers

1
Fogmeister On

It sounds like you have set the label "type" to "Attributed" in Interface Builder.

If this is the case then it is not the label that holds the text colour. It is the text itself.

If you replace the text with something else then the default text color of black will be used.

If you want to continue using Attributed text then you need to add a "foregroundColor" attribute to the text before setting it to the label.

The easier way round this is to change the label type to "Plain" in Interface Builder.

Of course, this depends on you having set it to Attributed.

0
Oleg Kovtun On

I think you shouldn't use default label color in the interface builder, just provide something else (black color or etc.).

0
Adam B On

I ran into a similar problem. Was stumping me completely, until I quit and relaunched the simulator. It wasn't enough to just close the window or rebuild. I had to cmd-q, then build and launch again. Magically fixed the issue. Annoying.. but worked for me