首页 > 代码库 > 自定义转场动画库
自定义转场动画库
自定义转场动画库
#import <QuartzCore/QuartzCore.h>
@interface MyCATransition : CATransition
// 参数说明:
/********************type**************/
// `fade‘, 渐变
// `moveIn‘ 进入,
// `push‘ 推出
// `reveal‘. 展现
// cube 立方
// suckEffect 吸收
// oglFlip 上下翻转
// rippleEffect 水滴
// pageCurl 卷页
// pageUnCurl 后翻页
// cameraIrisHollowOpen 开相机
// cameraIrisHollowClose 关相机
/********************subtype**************/
// fromLeft‘,
// `fromRight‘,
// `fromTop‘
// `fromBottom‘
/********************timingFunction**************/
// timingFunction:
// linear‘,
// `easeIn‘,
// `easeOut‘
// `easeInEaseOut‘
//
// 自定义转场动画
+ (MyCATransition *)catransitionWithType:(NSString *)type subType:(NSString *)subType duration:(double)duration timingFunction:(NSString *)timingName;
@end
#import "MyCATransition.h"
@implementation MyCATransition
+ (MyCATransition *)catransitionWithType:(NSString *)type subType:(NSString *)subType duration:(double)duration timingFunction:(NSString *)timingName {
// 转场动画
MyCATransition * animation = [MyCATransition animation];
animation.type = type;
animation.subtype = subType;
animation.duration = duration;
animation.timingFunction = [CAMediaTimingFunction functionWithName:timingName];
return animation;
}
@end
实例:
将自定义动画对象加到需要进行转场的layer层 就会实现动画的炫酷效果哦
MyCATransition * animation = [MyCATransition catransitionWithType:@"push" subType:@"fromBottom" duration:0.7 timingFunction:@"easeInEaseOut"];
[self.navigationController.view.layer addAnimation:animation forKey:@"animation"];
END
自定义转场动画库