#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