Usage of UILabel and UISlider in iPhone applications

Source: Internet
Author: User

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:

 
 
  1. IBOutlet UILabel *lab;  
  2.  IBOutlet UISlider *slid;  
  3.  IBOutlet UITextField *txt;  
  4.  IBOutlet UISlider *red;  
  5.  IBOutlet UISlider *green;  
  6.  IBOutlet UISlider *blue; 

Definition method:

 
 
  1. -(IBAction)add;  
  2. -(IBAction)addred;  
  3. -(IBAction)addgreen;  
  4. -(IBAction)addblue; 

Then in. The following method is added to the m file:

 
 
  1. -(Void) viewDidLoad // initialization settings
  2. {
  3. Lab. text = @ "123456789"; // set the initial value of Lable.
  4. Slid. minimumValue = 12; // set the bottom value of the font.
  5. Slid. maximumValue = 50; // set the maximum font size.
  6. Red. minimumValue = 0; // set the minimum value of Red to 0.
  7. Red. maximumValue = 1; // set the maximum value of Red to 1.
  8. Blue. minimumValue = 0; // set the minimum value of Blue to 0.
  9. Blue. maximumValue = 1; // set the maximum value of Blue to 1.
  10. Green. minimumValue = 0; // set the minimum value of Green to 0.
  11. Green. maximumValue = 1; // set the maximum value of Green to 1.
  12. [Lab setFont: [UIFont fontWithName: @ "DBLCDTempBlack" size: [slid value]; // initialize the font and size of the Label
  13. [Super viewDidLoad];
  14. }
  15. -(Void) didReceiveMemoryWarning
  16. {
  17. [Super didReceiveMemoryWarning];
  18. }
  19.  
  20. -(Void) add // control the font size
  21. {
  22. Int I = [slid value]; // obtain the UISlider value
  23. [Lab setFont: [UIFont fontWithName: @ "DBLCDTempBlack" size: I]; // set the font and size of the Label.
  24. Txt. text = [NSString stringWithFormat: @ "% d", I]; // get a TextField In the debugging phase to display the size.
  25. }
  26. -(IBAction) addred // set the Red value based on the UISlider Value
  27. {
  28. Float r = [red value];
  29. Float g = [green value];
  30. Float B = [blue value];
  31. [Lab setTextColor: [UIColor colorWithRed: r green: g blue: B alpha: 1];
  32. }
  33. -(IBAction) addgreen
  34. {
  35. Float r = [red value];
  36. Float g = [green value];
  37. Float B = [blue value];
  38. [Lab setTextColor: [UIColor colorWithRed: r green: g blue: B alpha: 1];
  39. }
  40. -(IBAction) addblue
  41. {
  42. Float r = [red value];
  43. Float g = [green value];
  44. Float B = [blue value];
  45. [Lab setTextColor: [UIColor colorWithRed: r green: g blue: B alpha: 1];
  46. }
  47. -(Void) dealloc
  48. {
  49. [Lab release];
  50. [Slid release];
  51. [Red release];
  52. [Blue release];
  53. [Green release];
  54. [Super dealloc];
  55. }

Final:

Summary: DetailsIPhoneApplication in progressUILabelAndUISliderThe usage is complete. I hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.