• 界面跳转动画-详解


    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];

     

    - (void)popToLastInterface {
        [self.navigationController popViewControllerAnimated:YES];
    }
    - (void)popToROOTInterface {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    - (void)popToIndexInterface {
        NSArray * array = self.navigationController.viewControllers;
        UIViewController * vc = [array objectAtIndex:0];
        [self.navigationController popToViewController:vc animated: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;

     

     

     

     

     

     

     

     

  • 相关阅读:
    19 个必须知道的 Visual Studio 快捷键
    面试感悟:一名3年工作经验的程序员应该具备的技能
    来自开发者技术前线 高级程序员,你需要养成这7个习惯
    来自极客头条的 15个常用的javaScript正则表达式
    来自极客头条的 35 个 Java 代码性能优化总结
    [Visual studio] Visual studio 2017添加引用时报错未能正确加载ReferenceManagerPackage包的解决方法
    [Visual Studio] 未能完成操作 不支持此接口
    未能加载文件或程序集“Benlai.SOA.Framework.Common, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。
    [Visual Studio] NuGet发布自定义包(Library Package)
    未能加载视图状态。正在向其中加载视图状态的控件树必须与前一请求期间用于保存视图状态的控件树相匹配。例如,当以动态方式添加控件时,在回发期间添加的控件必须与在初始请求期间添加的控件的类型和位置相匹配
  • 原文地址:https://www.cnblogs.com/StevenHuSir/p/INterfaceJump_Animation.html
Copyright © 2020-2023  润新知