Hi Im trying to change the text color of a UILabel in one of my views but having no luck.
Is there something quite obvious that Im not doing in this code?
self.nameTopRight.backgroundColor = [UIColor redColor]; self.nameBottomRight.textColor = [UIColor redColor];
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.
Xcode Getting started with Xcode Changing The Color SchemeWith the preference pane open you can click on the 'Fonts and Colors' tab. From here you can change the source AND console background and font colors.
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.
The question was already answered for the OP, but for the sake of other people who come here trying to change a label's text color, use the textColor
property:
Swift
myLabel.textColor = UIColor.red // or .red
Objective-C
myLabel.textColor = [UIColor redColor];
They need to be connected in Interface Builder.
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