iOS UIView packaged animations

Source: Internet
Author: User

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

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.