界面跳转动画-详解

Posted stevenhusir

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了界面跳转动画-详解相关的知识,希望对你有一定的参考价值。

001-修改根视图,利用导航Push

    UIViewController *vc = [[UIViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];

前提必须是根视图:

        HKMainViewController * homeVC = [HKMainViewController alloc] init];
        HKNavigationViewController * nav = [[HKNavigationViewController alloc] initWithRootViewController:homeVC];
        self.window.rootViewController = nav;
        [self.window makeKeyAndVisible];

返回:

[self.navigationController popViewControllerAnimated:YES];

002-Present方式

    UIViewController *vc = [[UIViewController alloc]init];
    [self presentViewController:vc animated:NO completion:nil];

返回:

[self dismissViewControllerAnimated:YES completion:nil];

003-修改ModalTransitionStyle风格    

typedef NS_ENUM(NSInteger, UIModalTransitionStyle) {

 

    UIModalTransitionStyleCoverVertical = 0,

 

    UIModalTransitionStyleFlipHorizontal __TVOS_PROHIBITED,

 

    UIModalTransitionStyleCrossDissolve,

 

    UIModalTransitionStylePartialCurl NS_ENUM_AVAILABLE_ios(3_2) __TVOS_PROHIBITED,

 

};

 

    UIViewController * vc = [[UIViewController alloc] init];

    vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;//平滑过渡

    [self presentViewController:destination animated:NO completion:nil];

    

返回:

[self dismissViewControllerAnimated:YES completion:nil];

004-CATransition过渡效果

    ViewController *VC = [[ViewController alloc]init];
    //创建动画
    CATransition *animation = [CATransition animation];
    //设置运动轨迹的速度
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    //设置动画类型为立方体动画
    animation.type = @"cube";
    //设置动画时长
    animation.duration =1.0f;
    //设置运动的方向
    animation.subtype =kCATransitionFromRight;
    //控制器间跳转动画
    [[UIApplication sharedApplication].keyWindow.layer addAnimation:animation forKey:nil];
   [self presentViewController:VC animated:NO completion:nil];

可选枚举:

typedef enum : NSUInteger {
    fade = 1,                   //淡入淡出
    push,                       //推挤
    reveal,                     //揭开
    moveIn,                     //覆盖
    cube,                       //立方体
    suckEffect,                 //吮吸
    oglFlip,                    //翻转
    rippleEffect,               //波纹
    pageCurl,                   //翻页
    pageUnCurl,                 //反翻页
    cameraIrisHollowOpen,       //开镜头
    cameraIrisHollowClose,      //关镜头
    curlDown,                   //下翻页
    curlUp,                     //上翻页
    flipFromLeft,               //左翻转
    flipFromRight,              //右翻转

} AnimationType;

 

 

 

 

 

 

 

 

 

以上是关于界面跳转动画-详解的主要内容,如果未能解决你的问题,请参考以下文章

Android开发 navigation的跳转动画实现

Vue仿微信app页面跳转动画

Android开发之Activity跳转动画以及finish动画

Android四大组件——Activity跳转动画淡出淡入滑出滑入自定义退出进入

在android编程中怎么实现activity的跳转动画

jQuery写出可调控自定义的平滑滚动效果(锚点跳转动画)