IPhoneApplication in progressUILabelAndUISliderUsage is the content to be introduced in this article.UILabelAndUISliderTo implement a simple instance, Let's first look at the details. This afternoon.UILabelAndUISliderI learned something. I feel like I have forgotten it.
First.Add the following code to the file area of h:
Declare variables:
- IBOutlet UILabel *lab;
- IBOutlet UISlider *slid;
- IBOutlet UITextField *txt;
- IBOutlet UISlider *red;
- IBOutlet UISlider *green;
- IBOutlet UISlider *blue;
Definition method:
- -(IBAction)add;
- -(IBAction)addred;
- -(IBAction)addgreen;
- -(IBAction)addblue;
Then in. The following method is added to the m file:
- -(Void) viewDidLoad // initialization settings
- {
- Lab. text = @ "123456789"; // set the initial value of Lable.
- Slid. minimumValue = 12; // set the bottom value of the font.
- Slid. maximumValue = 50; // set the maximum font size.
- Red. minimumValue = 0; // set the minimum value of Red to 0.
- Red. maximumValue = 1; // set the maximum value of Red to 1.
- Blue. minimumValue = 0; // set the minimum value of Blue to 0.
- Blue. maximumValue = 1; // set the maximum value of Blue to 1.
- Green. minimumValue = 0; // set the minimum value of Green to 0.
- Green. maximumValue = 1; // set the maximum value of Green to 1.
- [Lab setFont: [UIFont fontWithName: @ "DBLCDTempBlack" size: [slid value]; // initialize the font and size of the Label
- [Super viewDidLoad];
- }
- -(Void) didReceiveMemoryWarning
- {
- [Super didReceiveMemoryWarning];
- }
-
- -(Void) add // control the font size
- {
- Int I = [slid value]; // obtain the UISlider value
- [Lab setFont: [UIFont fontWithName: @ "DBLCDTempBlack" size: I]; // set the font and size of the Label.
- Txt. text = [NSString stringWithFormat: @ "% d", I]; // get a TextField In the debugging phase to display the size.
- }
- -(IBAction) addred // set the Red value based on the UISlider Value
- {
- Float r = [red value];
- Float g = [green value];
- Float B = [blue value];
- [Lab setTextColor: [UIColor colorWithRed: r green: g blue: B alpha: 1];
- }
- -(IBAction) addgreen
- {
- Float r = [red value];
- Float g = [green value];
- Float B = [blue value];
- [Lab setTextColor: [UIColor colorWithRed: r green: g blue: B alpha: 1];
- }
- -(IBAction) addblue
- {
- Float r = [red value];
- Float g = [green value];
- Float B = [blue value];
- [Lab setTextColor: [UIColor colorWithRed: r green: g blue: B alpha: 1];
- }
- -(Void) dealloc
- {
- [Lab release];
- [Slid release];
- [Red release];
- [Blue release];
- [Green release];
- [Super dealloc];
- }
Final:
Summary: DetailsIPhoneApplication in progressUILabelAndUISliderThe usage is complete. I hope this article will help you!