iOS之push present 动画

时间:2023-03-08 20:51:45

直接源码:

- (void) transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIView *) view

{

//创建CATransition对象

CATransition *animation = [CATransition animation];

//设置运动时间

animation.duration = 0.7f;

//设置运动type

animation.type = type;

if (subtype != nil) {

//设置子类

animation.subtype = subtype;

}

//设置运动速度

animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;

[view.layer addAnimation:animation forKey:@"animation"];

}

把此方法粘贴后。就可以 思考你要啥 动画了

typedef enum : NSUInteger {

Fade = 1,                   //淡入淡出

Push,                       //推挤

Reveal,                     //揭开

MoveIn,                     //覆盖

Cube,                       //立方体

SuckEffect,                 //吮吸

OglFlip,                    //翻转

RippleEffect,               //波纹

PageCurl,                   //翻页

PageUnCurl,                 //反翻页

CameraIrisHollowOpen,       //开镜头

CameraIrisHollowClose,      //关镜头

CurlDown,                   //下翻页

CurlUp,                     //上翻页

FlipFromLeft,               //左翻转

FlipFromRight,              //右翻转

} AnimationType;

如果是在父类写的此方法。子类直接调用。

[super transitionWithType:@"cude" WithSubtype:kCATransitionFromLeft ForView:self.navigationController.view];要啥 效果可以 自己尝试。Fight.