Example 1: Picture view Follow the point of the hand on the screen to change the size
- (void) viewdidload{[Super Viewdidload]; //Add gesturesUipangesturerecognizer *gesture =[[Uipangesturerecognizer alloc] init]; [Gesture addtarget:self Action: @selector (changesize:)]; [Self.view Addgesturerecognizer:gesture]; }- (void) Changesize: (uipangesturerecognizer*) tap{popspringanimation*springanimation =[Popspringanimation Animationwithpropertynamed:kpopviewframe]; Cgpoint Point=[Tap LocationInView:self.view]; Springanimation.tovalue= [Nsvalue Valuewithcgrect:cgrectmake (0,0, Point.x, Point.y)]; //Elastic ValueSpringanimation.springbounciness =20.0; //Elastic SpeedSpringanimation.springspeed =20.0; [_springview pop_addanimation:springanimation Forkey:@"Changeframe"];}
Example 2: Implementation of a pop-up contraction view of the effect, bounce out elastic effect, shrinkage has a smaller effect
- (void) viewdidload{[Super Viewdidload]; _showposition= CGRectMake ( the-147,5,147, the); _hideposition= CGRectMake ( the,5,0,0); _popview=[[Uiimageview alloc] initwithframe:_hideposition]; _popview.image= [UIImage imagenamed:@"Menu.png"]; [Self.view Addsubview:_popview]; Self.navigationItem.rightBarButtonItem= [[Uibarbuttonitem alloc] Initwithtitle:@"+"Style:uibarbuttonitemstyledone target:self Action: @selector (Showpop)]; //let the screen start counting (0,0) from the navigation bar if([Self respondstoselector: @selector (setedgesforextendedlayout:)]) {Self.edgesforextendedlayout=Uirectedgenone; }}- (void) showpop{if(_isopened) {[Self hidepop]; return; } _isopened=YES; Popspringanimation*positionanimation =[Popspringanimation Animationwithpropertynamed:kpopviewframe]; Positionanimation.fromvalue=[Nsvalue valuewithcgrect:_hideposition]; Positionanimation.tovalue=[Nsvalue valuewithcgrect:_showposition]; Positionanimation.springbounciness=15.0f; Positionanimation.springspeed=20.0f; [_popview pop_addanimation:positionanimation Forkey:@"frameanimation"];}- (void) hidepop{popbasicanimation*positionanimation =[Popbasicanimation Animationwithpropertynamed:kpopviewframe]; Positionanimation.fromvalue=[Nsvalue valuewithcgrect:_showposition]; Positionanimation.tovalue=[Nsvalue valuewithcgrect:_hideposition]; [_popview pop_addanimation:positionanimation Forkey:@"frameanimation"]; _isopened=NO;}
Example 3: Create two keys, add two animation effects, one of the keys is the animation changes the size, the other one modified Viewframe, as long as the coordinates and size can make a good animation
@interface Viewcontroller () @property (nonatomic, retain) UIView*button; @property (nonatomic, retain) UIView*popout; @property (ReadWrite, assign) BOOL timerrunning; @end @implementation Viewcontroller- (void) viewdidload{[Super Viewdidload]; _popout= [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"Timerpopout"]]; [_popout Setframe:cgrectmake (245, -,0,0)]; [Self.view Addsubview:_popout]; _button= [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"Timerbutton"]]; [_button Setframe:cgrectmake ( -, -, $, $)]; [Self.view Addsubview:_button]; _timerrunning=NO; [Self.view Addgesturerecognizer:[[uitapgesturerecognizer alloc] initwithtarget:self action: @selector (demoanimate:) ]];}- (void) Demoanimate: (uitapgesturerecognizer*) tap{_timerrunning= !_timerrunning; Popspringanimation*buttonanimation =[popspringanimation animation]; Buttonanimation.property=[Popanimatableproperty propertywithname:kpoplayersize]; if(_timerrunning) {Buttonanimation.tovalue= [Nsvalue Valuewithcgsize:cgsizemake (Panax Notoginseng,Panax Notoginseng)]; } Else{Buttonanimation.tovalue= [Nsvalue Valuewithcgsize:cgsizemake ( $, $)]; } buttonanimation.springbounciness=10.0; Buttonanimation.springspeed=10.0; [_button pop_addanimation:buttonanimation Forkey:@"Pop"]; Popspringanimation*popoutanimation =[popspringanimation animation]; Popoutanimation.property=[Popanimatableproperty Propertywithname:kpopviewframe]; if(!_timerrunning) {Popoutanimation.tovalue= [Nsvalue Valuewithcgrect:cgrectmake (245, -,0,Ten)]; } Else{Popoutanimation.tovalue= [Nsvalue Valuewithcgrect:cgrectmake ( the, -, the, -)]; } popoutanimation.velocity= [Nsvalue Valuewithcgrect:cgrectmake ( $,0, -, - $)]; Popoutanimation.springbounciness=10.0; Popoutanimation.springspeed=10.0; [_popout pop_addanimation:popoutanimation Forkey:@"Slide"];}
Facebook Open Source Animation library pop-Small Instance