iOS Development--ui Article Swift &uislider

Source: Internet
Author: User

UISlider

1  2     Overridefunc viewdidload () {3 super.viewdidload ()4         5Titlelabel.text =titlestring6         7         8         //Do any additional setup after loading the view.9         Ten          One          A          -         //Create -var slider:uislider = UISlider (Frame:cgrectmake ( -, -, $, -)) the          -         //Add to view - Self.view.addSubview (Slider) -          +         //Set minimum Value -Slider.minimumvalue =Ten +          A         //set the maximum value atSlider.maximumvalue = the -          -         //Set Default values -Slider.value = - -          -         //set the left-hand picture inSlider.setminimumtrackimage (UIImage (named:"Minimumtrackimage"), ForState:UIControlState.Normal) -          to         //set up a picture for another side +Slider.setmaximumtrackimage (UIImage (named:"Maximumtrackimage"), ForState:UIControlState.Normal) -          the          *          $         //read the value of the slider control:Panax Notoginsengvar value =Slider.value - println (value) the          +          A         //add notification to get value change theSlider.addtarget (Self, Action:"Slidervaluechange:", forControlEvents:UIControlEvents.ValueChanged) +          -         //continuous default is true, when set to false, only stop dragging will trigger Slidervaluechange: Method $Slider.continuous =false $          -          -          the         //-----Custom Sliders -         Wuyi         //define left and right pictures thevar stetchlefttrack:uiimage! = UIImage (named:"Lefttrack.png") -var stetchrighttrack:uiimage! = UIImage (named:"Righttrack.png") Wu         -         //defining the slider picture Aboutvar thumbimage:uiimage! = UIImage (named:"Thumbimage.png") $          -         //Create a UISlider object -var newslider:uislider = UISlider (Frame:cgrectmake ( -, -,257,8)) -Newslider.backgroundcolor =Uicolor.clearcolor () ANewslider.minimumvalue =0.5 +Newslider.maximumvalue =1.5 theNewslider.value =1.0 -          $         //set left and right picture the newslider.setminimumtrackimage (Stetchlefttrack, ForState:UIControlState.Normal) the newslider.setmaximumtrackimage (Stetchrighttrack, ForState:UIControlState.Normal) the          the         //set the picture to drag the dots, and note that the uicontrolstate.highlighted state is added, otherwise the slider becomes the native control when you drag the slider - newslider.setthumbimage (Thumbimage, ForState:UIControlState.Normal) in newslider.setthumbimage (Thumbimage, forState:UIControlState.Highlighted) the          the         //add notification to get value change AboutNewslider.addtarget (Self, Action:"Newslidervaluechange:", forControlEvents:UIControlEvents.ValueChanged) the          the          the         //Slide the event after dragging +Newslider.addtarget (Self, Action:"Newslidertouchupinside:", ForControlEvents:UIControlEvents.TouchUpInside) -          the Self.view.addSubview (Newslider)Bayi     } the  the     Overridefunc didreceivememorywarning () { - super.didreceivememorywarning () -         //Dispose of any resources the can be recreated. the     } the      the  the     /* - //MARK:-Navigation the  the //In a storyboard-based application, you'll often want to do a little preparation before navigation the override func Prepareforsegue (segue:uistoryboardsegue!, sender:anyobject!) {94 //Get The new view controller using Segue.destinationviewcontroller. the //Pass The selected object to the new view controller. the     } the     */98      About      -     //how the slider value changes the trigger101Func Slidervaluechange (sender:anyobject?)102     {103 //var newslider:uislider = sender as UISlider104          the         //May 2015 after 2 revision106var Newslider:uislider = Sender as!UISlider107var value =Newslider.value108 println (value)109     } the     111      the     //Custom Sliders Use113      the     //Drag Events theFunc Newslidervaluechange (sender:anyobject?) the     {117 //var newslider:uislider = sender as UISlider118         119         //May 2015 after 2 revision -var Newslider:uislider = Sender as!UISlider121 println (Newslider.value)122     }123     124     //Slide the event after dragging theFunc newslidertouchupinside (sender:anyobject?)126     {127 //var newslider:uislider = sender as UISlider -         129         //May 2015 after 2 revision thevar Newslider:uislider = Sender as!UISlider131 println (Newslider.value) the     }133     

iOS Development--ui Article Swift &uislider

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.