1扣泊、轉(zhuǎn)場動畫簡單介紹
CAAnimation的子類近范,用于做轉(zhuǎn)場動畫,能夠為層提供移出屏幕和移入屏幕的動畫效果延蟹。iOS比Mac OS X的轉(zhuǎn)場動畫效果少一點
UINavigationController就是通過CATransition實現(xiàn)了將控制器的視圖推入屏幕的動畫效果
屬性解析:
type:動畫過渡類型
subtype:動畫過渡方向
startProgress:動畫起點(在整體動畫的百分比)
endProgress:動畫終點(在整體動畫的百分比)
2评矩、轉(zhuǎn)場動畫效果類型
3、圖片瀏覽器的轉(zhuǎn)場動畫效果
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
// 圖片索引
@property (nonatomic,assign) int index;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.index = 1;
}
- (IBAction)previousImageAnimation:(UIButton *)sender {
self.index--;
if (self.index<1) {
self.index=11;
}
self.iconView.image=[UIImage imageNamed: [NSString stringWithFormat:@"%03d.jpg",self.index]];
//創(chuàng)建核心動畫
CATransition *caanimation=[CATransition animation];
//告訴要執(zhí)行什么動畫
//設(shè)置過度效果
caanimation.type=@"cube";
//設(shè)置動畫的過度方向(向左)
caanimation.subtype=kCATransitionFromLeft;
//設(shè)置動畫的時間
caanimation.duration=2.0;
//添加動畫
[self.iconView.layer addAnimation:caanimation forKey:nil];
}
- (IBAction)nextImageAnimation:(UIButton *)sender {
self.index++;
if (self.index>11) {
self.index = 1;
}
self.iconView.image=[UIImage imageNamed: [NSString stringWithFormat:@"%03d.jpg",self.index]];
//創(chuàng)建核心動畫
CATransition *caanimation=[CATransition animation];
//告訴要執(zhí)行什么動畫
//設(shè)置過度效果
caanimation.type=@"cube";
//設(shè)置動畫的過度方向(向右)
caanimation.subtype=kCATransitionFromRight;
//設(shè)置動畫的時間
caanimation.duration=2.0;
//添加動畫
[self.iconView.layer addAnimation:caanimation forKey:nil];
}
@end