#import "ViewController.h" @interface Viewcontroller () {UIButton *btn;} @end @implementation viewcontroller-(void) viewdidload {[Super viewdidload]; Btn=[uibutton Buttonwithtype:uibuttontypesystem]; Btn.frame=cgrectmake (30, 30, 50, 50); Btn.backgroundcolor=[uicolor Redcolor]; [Btn settitle:@ "button" forstate:uicontrolstatenormal]; [Btn addtarget:self Action: @selector (Btnclick:) forcontrolevents:uicontroleventtouchupinside]; [Self.view ADDSUBVIEW:BTN]; }//uiviewanimationwithblocks-(void) Btnclick: (ID) sender{//This method parameter 1: Animation duration parameter 2: Modified View Property [UIView Animatewithduration:2 animations:^{Btn.backgroundcolor=[uicolor Blackcolor]; }]; This method parameter 1: Animation time length parameter 2: Modified view property Parameter 3: Animation complete callback [UIView Animatewithduration:3 animations:^{Btn.backgroundcolor=[uicolor Redcolor]; } completion:^ (BOOL finished) {NSLog (@ "Completion1"); }]; /* Uiviewanimationoptionlayoutsubviews//Submit animation when the layout child controls, indicating that the child controls will be animated with the parent control. UiviewanimationoptionallowuserinteractioN//Animation allows users to communicate, such as touch uiviewanimationoptionbeginfromcurrentstate//start from the current state animation uiviewanimationoptionrepeat//Animation Unlimited Repeat Uiviewanimationoptionautoreverse//Execute animation loop, if set animation infinite repetition uiviewanimationoptionoverrideinheritedduration//Ignore Outer animation nesting Execution time Uiviewanimationoptionoverrideinheritedcurve//ignores the temporal variation curve of the outer animation nesting uiviewanimationoptionallowanimated Content//animate by changing properties and redrawing if key does not commit the animation will use the snapshot uiviewanimationoptionshowhidetransitionviews//To replace the animated effect of adding the removed layer in an explicit manner Uiviewanimationoptionoverrideinheritedoptions//Ignore options for nested inheritance//Time function curve related uiviewanimationoptioncurveeaseinout/ /Time curve function, from slow to fast uiviewanimationoptioncurveeasein//Time curve function, from slow to very fast uiviewanimationoptioncurveeaseout//Time curve function, from fast to Slow Uiviewanimationoptioncurvelinear//time curve function, constant speed//Transition animation related Uiviewanimationoptiontransitionnone//no transition animation Uiviewanimationoptiontransitionflipfromleft//Transitions from left flip uiviewanimationoptiontransitionflipfromright//transitions from right to flip UiviewanimationoptIontransitioncurlup//Roll up Transitions uiviewanimationoptiontransitioncurldown//down volume transitions Uiviewanimationoptiontransitioncro Ssdissolve//Transitions Cross disappear uiviewanimationoptiontransitionflipfromtop//transitions from top to upside uiviewanimationoptiontransitionflipf Rombottom//transition from bottom to///parameter 1 animation time length parameter 2 delay Time parameter 3 enumeration see above comment parameter 4 change View property parameter 5 callback when animation is complete [UIView Animatekeyframeswithdurati On:2 delay:2 options:uiviewkeyframeanimationoptionbeginfromcurrentstate animations:^{Btn.backgroundColor=[UIColo R Greencolor]; CGRect Frame=btn.frame; if (frame.origin.x<self.view.frame.size.width-20) {frame.origin.x+=20; } else {frame.origin.x=0; } btn.frame=frame; } completion:^ (BOOL finished) {NSLog (@ "Completion2"); }]; Transition animation [UIView transitionFromView:self.view toview:btn Duration:5 Options:uiviewanimationoptiontransitioncurldown completion:^ (BOOL finished) {NSLog (@ "Completion3"); }]; [UIView transitionWithView:self.view Duration:5 Options:uiviewanimationoptiontransitionflipfrombottom animations:^ {Btn.backgroundcolor=[uicolor Redcolor]; } completion:^ (BOOL finished) {NSLog (@ "Completion4"); }]; }-(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end
Under UIView animation