1 #import "NJViewController.h"2 3 @interfaceNjviewcontroller ()4@property (Weak, nonatomic) Iboutlet UIView *Cutomview;5 6 @end7 8 @implementationNjviewcontroller9 Ten- (void) Viewdidload One { A [Super Viewdidload]; - - } the- (void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event - { - -[UIView transitionWithView:self.view Duration:1.0Options0animations:^{ +NSLog (@"Animations"); - //the animation to be performed + [UIView setanimationtransition:uiviewanimationtransitionflipfromright forView:self.view Cache:yes]; A at} completion:^(BOOL finished) { -NSLog (@"Completion"); - //animations that are executed after execution finishes - }]; - - } in -- (void) Test2 to { +[UIView animatewithduration:2.0animations:^{ -NSLog (@"before the animation:%@", Nsstringfromcgpoint (Self.cutomView.center)); the //code that needs to execute the animation *Self.cutomView.center = Cgpointmake ( -, -); $ Panax Notoginseng} completion:^(BOOL finished) { - //code that executes after the animation finishes executing theNSLog (@"after the animation is executed:%@", Nsstringfromcgpoint (Self.cutomView.center)); + A }]; the } + -- (void) Test1 $ { $ //1. Create a core animation - //Note: If you change the position of the layer through the core animation, it appears to have changed on the surface, but it is essentially unchanged. -Cabasicanimation *anima =[cabasicanimation animation]; theAnima.keypath =@"position"; -Anima.tovalue = [Nsvalue valuewithcgpoint:cgpointmake ( -, -)];Wuyi theAnima.removedoncompletion =NO; -Anima.fillmode =kcafillmodeforwards; Wu -Anima.Delegate=Self ; About $ //2. Add a core animation - [Self.cutomView.layer Addanimation:anima forkey:nil]; - } - A- (void) Animationdidstart: (Caanimation *) Anim + { theNSLog (@"%@ before core animations are executed", Nsstringfromcgpoint (self.cutomView.layer.position)); - $ } the the- (void) Animationdidstop: (Caanimation *) Anim finished: (BOOL) Flag the { theNSLog (@"Core Animation completed%@", Nsstringfromcgpoint (self.cutomView.layer.position)); - } in the- (void) Test the { About //1.UIVIEW encapsulated animations that do not bounce after the animation is finished theNSLog (@"before the animation:%@", Nsstringfromcgpoint (Self.cutomView.center)); the [UIView Beginanimations:nil context:nil]; the[UIView setanimationduration:2.0]; + [UIView setanimationdelegate:self]; - [UIView setanimationdidstopselector: @selector (Didstopanimatino)]; theSelf.cutomView.center = Cgpointmake ( -, -);Bayi [UIView commitanimations]; the the } - -- (void) Didstopanimatino the { theNSLog (@"animation execution Complete%@", Nsstringfromcgpoint (Self.cutomView.center)); the } the - the the the @end
iOS UIView packaged animations