//
Viewcontroller.m
Ui-no-38-1 Basic Animation Example 1
//
Created by Wei Rong on 15/9/17.
Copyright (c) 2015 Wei Rong. All rights reserved.
//
/*
Cakeyframeanimation also belongs to Capropertyanimation
Keyframe animation allows us to control the animation effect precisely it is the principle of the animation sequence inside the more critical frame out to set his animation effect
The Values property performs the path of the animation track
The Path property performs an array of animation tracks
*/
#import "ViewController.h"
@interface Viewcontroller ()
{
Calayer *petallayer;
}
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Self.view.backgroundColor = [Uicolor Whitecolor];
Uiimageview *imageview = [[Uiimageview alloc] Initwithframe:[uiscreen mainscreen].bounds];
NSString *path = [[NSBundle mainbundle] pathforresource:@ "deciduous" oftype:@ "jpg"];
Imageview.image = [UIImage Imagewithcontentsoffile:path];
[Self.view Addsubview:imageview];
[Self addpetal];
}
-(void) Addpetal {
NSString *path = [[NSBundle mainbundle] pathforresource:@ "petal" oftype:@ "jpg"];
UIImage *petal = [UIImage Imagewithcontentsoffile:path];
Petallayer = [[Calayer alloc] init];
Petallayer.bounds = CGRectMake (0, 0, petal.size.width, petal.size.height);
Petallayer.position = Cgpointmake (150, 250);
Petallayer.contents = (ID) petal. Cgimage;
[Self.view.layer Addsublayer:petallayer];
}
-(void) Dropanimation {
Cabasicanimation *animation = [cabasicanimation animationwithkeypath:@ "position"];
Animation.fromvalue = [Nsvalue valueWithCGPoint:petalLayer.position];
Animation.tovalue = [Nsvalue valuewithcgpoint:cgpointmake (150, 600)];
Animation.duration = 5;
Animation.removedoncompletion = NO;
Animation.fillmode = Kcafillmodeboth;
[Petallayer addanimation:animation forkey:@ "Show"];
}
-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) Event {
[Self dropanimation];
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}
@end
Keyframe Animation (2) The beating of the heart