iOS Development Tips-use UISlider to adjust the range of values

Source: Internet
Author: User

(Swift)

Import UIKitclassViewcontroller:uiviewcontroller {var slider:uislider!func slidervaluechanged (slider:uislider) {println ("Slider ' s new value is \ (slider.value)")    }        Overridefunc viewdidload () {super.viewdidload () slider= UISlider (Frame:cgrect (x:0Y:0, Width: $, Height: at)) Slider.center=View.center Slider.minimumvalue=0Slider.maximumvalue= -Slider.value= Slider.maximumvalue/2.0                //Customize slider and highlighted with own imageSlider.setthumbimage (UIImage (named:"Thumbnormal"), Forstate:. Normal) Slider.setthumbimage (UIImage (named:"thumbhighlighted"), Forstate:. Highlighted) Slider.addtarget (Self, Action:"slidervaluechanged:", forControlEvents:. valuechanged) View.addsubview (Slider)}}

(OBJECTIVE-C)

#import "ViewController.h"@interfaceViewcontroller () @property (nonatomic, strong) UISlider*Slider;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; Self.slider= [[UISlider alloc] Initwithframe:cgrectmake (0.0f,        0.0f,        200.0f,        23.0f)]; Self.slider.center=Self.view.center; Self.slider.minimumValue=0.0f; Self.slider.maximumValue=100.0f; Self.slider.value= Self.slider.maximumValue/2.0; //Customize slider and highlighted with own image[Self.slider setthumbimage:[uiimage imagenamed:@"Thumbnormal.png"] Forstate:uicontrolstatenormal]; [Self.slider setthumbimage:[uiimage imagenamed:@"Thumbhighlighted.png"] forstate:uicontrolstatehighlighted];        [Self.view AddSubview:self.slider]; [Self.slider addtarget:self Action: @selector (slidervaluechanged:) forcontrolevents:uicontroleventvaluechange d];}

iOS Development Tips-use UISlider to adjust the range of values

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.