Object-c inside the animation animation effect, the core animation

Source: Internet
Author: User

#import "CoreAnimationViewController.h"

@interface Coreanimationviewcontroller ()
@property (nonatomic, strong) UIView *myview;

@end

@implementation Coreanimationviewcontroller

-(void) Viewdidload {
[Super Viewdidload];
Self.view.backgroundColor = [Uicolor Whitecolor];

Self.myview = [[UIView alloc] initwithframe:cgrectmake (100, 100, 100, 100)];
Self.myView.backgroundColor = [Uicolor Cyancolor];
[Self.view Addsubview:_myview];
-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{

Used to rotate the

Cabasicanimation *base = [cabasicanimation animationwithkeypath:@ "transform.rotation"];

Set duration
Base.duration = 1;
Instantaneous needle rotation from * * to * *
Base.fromvalue = @0;
Base.tovalue = @ (m_pi_2);
[Self.myView.layer addanimation:base forkey:@ "base"];

}

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{
For a range of color variations

Cakeyframeanimation *color = [cakeyframeanimation animationwithkeypath:@ "BackgroundColor"];
Color.duration = 10;
ID k1 = (ID) [Uicolor bluecolor]. Cgcolor;
ID k2 = (ID) [Uicolor cyancolor]. Cgcolor;
ID K3 = (ID) [Uicolor magentacolor]. Cgcolor;
ID K4 = (ID) [Uicolor graycolor]. Cgcolor;
Color.values = @[k1, K2, K3, K4];
Add animations
[Self.myView.layer addanimation:color forkey:@ "Color"];

}

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{
Used for a series of unknown changes
Cakeyframeanimation *position = [cakeyframeanimation animationwithkeypath:@ "position"];
Position.duration = 2;
Nsvalue *v1 = [Nsvalue valuewithcgpoint:cgpointmake (0, 0)];
Nsvalue *v2 = [Nsvalue valuewithcgpoint:cgpointmake ([UIScreen mainscreen].bounds.size.height-100, 0)];
Nsvalue *v3 = [Nsvalue valuewithcgpoint:cgpointmake ([UIScreen mainscreen].bounds.size.width-100, [UIScreen mainScreen ].BOUNDS.SIZE.HEIGHT-100)];
Nsvalue *v4 = [Nsvalue valuewithcgpoint:cgpointmake (0, [UIScreen mainscreen].bounds.size.height-100)];
Nsvalue *v5 = [Nsvalue valuewithcgpoint:cgpointmake (0, 0)];
Position.values = @[v1,v2,v3,v4,v5];
Position.keytimes = @[@ (0.1), @ (0.4), @ (0.5), @ (0.8), @1];
[Self.myView.layer addanimation:position forkey:@ "position"];

}

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{
Animation Group
Combined add-on animations
Caanimationgroup *group = [Caanimationgroup animation];
Group.duration = 2;
Group.animations = @[color,position];
[Self.myView.layer addanimation:group forkey:@ "group"];

}

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{
Toggle Effects
Catransition *transition = [catransition animation];
Transition.duration = 2;
Type of switchover
Transition.type = @ "Cube";
Set the type of sub-switch
Transition.subtype = Kcatransitionfromleft;
[Self.myView.layer addanimation:transition forkey:@ "transition"];

}

Object-c inside the animation animation effect, the core animation

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.