IOS long-press control and iOS long control

Source: Internet
Author: User

IOS long-press control and iOS long control

Preface

On the Internet, we can see that the effect of a button's long-pressed control is good. A diamond increases from the center to the two sides.

Principle

In red, the view is placed on the control. The options are view, normalLable, highlightLabel, And button from top to bottom.

The View is rotated 45 degrees clockwise.

Click the button in the control to trigger the listener event.

Press the button to increase the view height and change the transparency of the two labels.

Lift: zoom down the view height and change the transparency of the two labels.

The extra black color can be hidden if it is not displayed beyond the parent view, enabling the center to spread out.

Some code:

Long-pressed listener

1-(void) buttonTouchDownAndDragEnter {2 NSLog (@ "Do not loosen long press"); 3 4 [self removeShowViewAndLabelLayer]; 5 [UIView animateWithDuration :( self. toEndDuration <= 0? TIME_END_DURATION: self. toEndDuration) 6 animations: ^ {7 [self showShowView]; 8} completion: ^ (BOOL finished) {9 if (finished = YES) {10 self. isEND = YES; 11} 12}]; 13}

Some methods

-(Void) showShowView {self. showView. bounds = CGRectMake (0, 0, SHOW_VIEW_WIDTH, (self. animationWidth <= 0? SHOW_VIEW_WIDTH: self. animationWidth); self. showView. alpha = 1; self. normalLabel. alpha = 0.f; self. highlightLabel. alpha = 1.f;} // hide showView and change normal and highlighted state-(void) hiddenShowView {self. showView. bounds = CGRectMake (0, 0, SHOW_VIEW_WIDTH, 0); self. showView. alpha = 0; self. normalLabel. alpha = 1.f; self. highlightLabel. alpha = 0.f;} // remove the previous animation-(void) removeShowViewAndLabelLayer {self. showView. bounds = (CALayer *) self. showView. layer. presentationLayer ). bounds; self. showView. alpha = (CALayer *) self. showView. layer. presentationLayer ). opacity; self. normalLabel. alpha = (CALayer *) self. normalLabel. layer. presentationLayer ). opacity; self. highlightLabel. alpha = (CALayer *) self. highlightLabel. layer. presentationLayer ). opacity; // remove the animation status [self. showView. layer removeAllAnimations];}

Demo link: http://pan.baidu.com/s/1eRckm4q

 

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.