Coreanimation and view animations

Source: Internet
Author: User

1 //2 //VIEWCONTROLLER.M3 //caanimationandviewanimation4 //5 //Created by Ys on 15/11/22.6 //Copyright (c) 2015 Ys. All rights reserved.7 //8 9 #import "ViewController.h"Ten  One @interfaceViewcontroller () A@property (Weak, nonatomic) Iboutlet UIView *Blackview; -  - @end the  - @implementationViewcontroller -  -- (void) Viewdidload { + [Super Viewdidload]; - } +  A-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event at { - //[self diycacoreanimation]; - //[self viewAnimation1]; - //[self viewAnimation2]; - [self viewAnimation3]; -      in } - /** to * The problem with the core animation is 1. Its direct operation layer, and the view layer is not enough object-oriented. + * The properties of the 2.layer have not changed. The layer animation is an illusion, and the position property of the layer has never changed during the execution of the animation. - * Therefore in actual development, unless some effects are difficult to achieve, it is generally used to animate the view the  */ *-(void) Diycacoreanimation $ {Panax NotoginsengCabasicanimation *anim =[cabasicanimation animation]; -Anim.keypath =@"position"; theAnim.tovalue = [Nsvalue valuewithcgpoint:cgpointmake ( $, $)]; +Anim.duration =0.5; AAnim.removedoncompletion =NO; theAnim.fillmode =kcafillmodeforwards; +Anim.Delegate=Self ; - [Self.blackView.layer Addanimation:anim forkey:nil]; $  $ } -  --(void) Animationdidstop: (Caanimation *) Anim finished: (BOOL) Flag the { -     //Diycacoreanimation After the animation is finished print the Position property of the discovered layer has never changed.WuyiNSLog (@"%@", Nsstringfromcgpoint (self.blackView.layer.position)); the } -  Wu-(void) ViewAnimation1 - { About [UIView Beginanimations:nil context:nil]; $Self.blackView.center = Cgpointmake ( $, $); - [UIView commitanimations]; -NSLog (@"%@", Nsstringfromcgpoint (Self.blackView.center)); - } A  +-(void) ViewAnimation2 the { -[UIView animatewithduration:1.0animations:^{ $Self.blackView.center = Cgpointmake ( $, $); the} completion:^(BOOL finished) { theNSLog (@"%@", Nsstringfromcgpoint (Self.blackView.center)); the     }]; the } -  in-(void) ViewAnimation3 the { the[UIView transitionWithView:self.blackView Duration:TenOptions:uiviewanimationoptiontransitionflipfromright animations:^{ About} completion:^(BOOL finished) { the     }]; the } the @end

Coreanimation and view 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.