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