Change Xcode label text color using RGB values

Working with xCode 4.5.1 Interface Constructor:

When I try to change the text color property of a label using RGB values, the background color is automatically changed to the same value as well.

In other words:

When we set RGB values ​​for the text color of the labels, the background color also changes if we don't use the sliders.

How do you make sure that only the text color changes and not the background?

+3


source to share


2 answers


UILabel

class has properties textColor

and backgroundColor

. You can control them.

label.textColor = [UIColor greenColor];
label.backgroundColor = [UIColor clearColor];

      



to work with it through Interface Builder, you have to select your label, then go to the attribute inspector. There you will find a section called Label. There is a Color tab. this is for the text color. In the section below the label there is a section called "View". It contains the Background tab. You can set the background color there

+12


source


first you need to create 3 uislider on ViewController.h

in viewController.m



-(IBAction)Sliders{

label.textColor = [UIColor ColorWithRed:RSlider.value green:GSlider blue:BSlider alpha:1.0f];

}

      

the connection must be "Value Changed"

+3


source







All Articles