Segmented controls (Uisegmentedcontrol) and slider controls (UISlider) in iOS

Source: Internet
Author: User

#import"RootViewController.h"@interface Rootviewcontroller () @end @implementation Rootviewcontroller- (void) viewdidload {[Super viewdidload]; //Do any additional setup after loading the view. //Segmented Control//1. Creating a control    /*Nsarray *items = @[@ "tap", @ "long press", @ "sweep", @ "Pan", @ "pinch", @ "rotate"];    Uisegmentedcontrol *segcontrol = [[Uisegmentedcontrol alloc] initwithitems:items];    Segcontrol.frame = CGRectMake (10, 100, 300, 30);    [Segcontrol addtarget:self Action: @selector (Handlesegcontrol:) forcontrolevents:uicontroleventvaluechanged];    Sets the default selected Segment Segcontrol.selectedsegmentindex = 2;    Set the text displayed on the segment [Segcontrol settitle:@ "Big breasted Beauty" forsegmentatindex:2];    Segcontrol.tintcolor = [Uicolor Graycolor];    Set the render color of a segmented control [Segcontrol setwidth:70 forsegmentatindex:2];    2. Add to Parent view [Self.view Addsubview:segcontrol];        3. Release [Segcontrol release]; */            //Slider Control//1. Creating a control    /*UISlider *slider = [[UISlider alloc] Initwithframe:cgrectmake (10, 300, 300, 30)];    Set slider minimum value slider.minimumvalue = 0.0;    Set slider Maximum value Slider.maximumvalue = 1.0;    Add response is event [slider addtarget:self action: @selector (Handleslider:) forcontrolevents:uicontroleventvaluechanged];    Sets whether the response event is continuously triggered in the process of sliding slider.continuous = NO;    2. Add to Parent view [Self.view Addsubview:slider];    3. Release [slider release]; */        //Picture ObjectUIImage *image = [UIImage imagenamed:@"Iphone.png"]; Uiimageview*imageview =[[Uiimageview alloc] initwithimage:image]; Imageview.frame= CGRectMake ( -, -,260,260/image.size.width*image.size.height); //play a dynamic pictureNsmutablearray *imagearray = [Nsmutablearray arraywithcapacity:1];  for(inti =1; I <= -; i++) {NSString*imagename = [NSString stringWithFormat:@"2250_3650903_179fb89ae279fae-%d (dragged). TIFF", I]; UIImage*image =[UIImage Imagenamed:imagename]; //Iamge Object added to Imagearray[Imagearray Addobject:image]; } imageview.animationimages=Imagearray; //set the time to play a group of animationsImageview.animationduration =0.8; //set number of repetitions//imageview.animationrepeatcount = 1; //2. Start Playback[ImageView startanimating]; //Open user interaction, which is turned off by default, and Uilabel user interaction is also turned off.imageview.userinteractionenabled =YES;    [Self.view Addsubview:imageview];        [ImageView release]; /*//Basic control objects such as buttons and sliders for base class Uicontrol Uitextfield UIButton uisegmentedcontrol UISlider Uiswitch Uistepper Uigesturerecognizer*/        //Uiresponder                        }- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}#pragmaSlider Response Event-(void) Handleslider: (UISlider *) slider{NSLog (@"%.2f", Slider.value);}#pragmaMark--handle Segment Control-(void) Handlesegcontrol: (Uisegmentedcontrol *) segmentcontrol{Switch(segmentcontrol.selectedsegmentindex) { Case 0: NSLog (@"Light Pat");  Break;  Case 1: NSLog (@"Long Press");  Break;  Case 2: NSLog (@"Cleaning");  Break;  Case 3: NSLog (@"panning");  Break;  Case 4: NSLog (@"kneading");  Break;  Case 5: NSLog (@"Rotate");  Break; default:             Break; }} @end

Segmented controls (Uisegmentedcontrol) and slider controls (UISlider) in iOS

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.