"Objective-c Study record" 40th day

Source: Internet
Author: User

Playing a few controls and gestures today reminds me of the time I used to play unity, drag controls, set properties, and write some corresponding values.

Gesture

Steps to use gestures:

1. Create a gesture that meets your needs, and when you create it, associate a gesture to trigger the method

2. Configure the related properties of gestures

3. Add gestures to the view on which you want to perform the action

4. Implement the Gesture method, when the touch occurs, the gesture recognizer recognizes the corresponding touch, the association method will be executed

Pat gesture

1UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (tapaction:)];2 //Set gestures3 //1. Number of fingers triggering gestures4tap.numberoftouchesrequired =1;5 //2. Number of taps to trigger gestures6tap.numberoftapsrequired =2;7 //3. Let ImageView add a tap gesture8[ImageView Addgesturerecognizer:tap];

Pat Gesture Event

1 -(void) Tapaction: (UITapGestureRecognizer *) Tap {2 }

Swipe gestures

1 uiswipegesturerecognizer *swipe = [[Uiswipegesturerecognizer alloc] initwithtarget:self action:@ Seletor (swipeaction:)]; 2 // Gesture Direction 3 swipe.direction = uiswipegesturerecognizerdirectiondown; 4 // let ImageView add a tap gesture 5 [ImageView addgesturerecognizer:swipe];

Swipe gesture Events

1 -(void) Swipeaction: (Uiswipegesturerecognizer *) swipe {2 }

Long-Press gestures

1 uilongpressgesturerecognizer *longpress = [[Uilongpressgesturerecognizer alloc] Initwithtarget:self Action: @selector (longpress:)]; 2 // the shortest time triggered by a long press gesture, the default is 0.5 3 3.0 ; 4 // Let ImageView add a long press gesture 5 [ImageView addgesturerecognizer:longpress];

Zoom gesture

Uipinchgesturerecognizer *pinch = [[Uipinchgesturerecognizer alloc] initwithtarget:self action: @seletor (pinaction:)] ;

Scaling gesture Events

1- (void) Pinchaction: (Uipinchgesturerecognizer *) Pinch {2      //get the view you want to scale3Uiimageview *imageview = (Uiimageview *) Pinch.view;4      5      //changing the deformation properties of ImageView6      //The first parameter is the transform that needs to exist, the second parameter is the scaling scale in the x direction, and the third parameter is the scaling scale in the y direction7Imageview.transform =Cgaffinetransformscale (Imageview.transform, Pinch.scale, Pinch.scale);8Pinch.scale =1;9       //orTen //imageview.transform = Cgaffinetransformmakescale (Pinch.scale, pinch.scale); One}

Rotate gestures

Uirotationgesturerecognizer *rotate = [[Uirotationgesturerecognizer alloc] initwithtarget:self action: @selector ( Rotateaction:)];

Rotate gesture Events

1- (void) Rotateaction: (Uirotationgesturerecognizer *) Rotate {2      //get the view you want to rotate3Uiimageview *imageview = (Uiimageview *) Rotate.view;4      5      //changing the deformation properties of ImageView6      //Rebound Rotation7 //imageview.transform = cgaffinetransformmakerotation (rotate.rotation);8Imageview.transform =cgaffinetransformrotate (Imageview.transform, rotate.rotation);9Rotate.rotation =0;Ten}

Panning gestures

Uipangesturerecognizer *pan = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (panaction:)];

Panning Gesture Events

1- (void) Panaction: (Uipangesturerecognizer *) Pan {2     //get the view you want to pan3Uiimageview *imageview = (Uiimageview *) Pan.view;4     5Cgpoint p =[Pan Translatininview:imageview];6     //Change the location properties of a view7Imageview.transform =cgaffinetransformtranslate (Imageview.transform, p.x, p.y);8 [Pan Settranslation:cgpointzero Inview:imageview];9}

Uiswitch

1.initWithFrame:. Initialization method, the width and height of this frame is meaningless, because the size of the system switch control is deterministic.

2.onTintColor. Sets the color of the switch when it is turned on.

3.tintColor. Sets the color of the switch style.

4.thumbTintColor. Sets the color of the switch button.

5.onimage/offimage. Sets the picture when the switch is on/off (IOS 7 no longer plays any role).

6.on. Switch status.

7.seton:animated:. Manually set the switch state, two parameters are of type bool.

UISlider

1.initWithFrame:. Initialize the method.

2.minimumValue. Sets the minimum value of the slider.

3.mamximumValue. Sets the maximum value of the slider.

4.value. Sets the current value of the slider.

5.minimumTrackTintColor. Defines the color across the area.

Uisegmentedcontrol

1.initWithItems:. Initialize the method, the parameter can be a string, an array of pictures.

2.selectedSegmentIndex. Specifies the selected segment and returns the index value of the selected segment.

3.tintColor. Sets the color of the Segmentedcontrol bar.

4.segmentedControlStyle. Set the appearance style (deprecated).

5.momentary. Sets whether to revert to the original after clicking.

6.settile:forsegmentatindex:. Sets the title for the segment that specifies the subscript, the first argument is a string, and the second parameter is the subscript value.

7.setimage:forsegmentatindex:. Sets the picture for the segment that specifies the subscript, the first argument is a picture, and the second parameter is the subscript value.

8.setenable:forsegmentatindex:. Sets whether the specified index can be point, the first parameter is a bool value, and the second parameter is the subscript value.

9.isEnableForSegmentAtIndex:. Determines whether the specified index can be dot and returns a bool value.

Uipagecontrol

1.initWithFrame:. Initialize the method.

2.numberOfPages. Specifies the number of pages, that is, the number of points.

3.currentPage. Specifies the value of the Pagecontrol, which is the selected point.

"Objective-c Study record" 40th day

Related Article

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.