zoukankan      html  css  js  c++  java
  • iOS开动画效果之──实现 pushViewController 默认动画效果

    在开发中,视图切换会常常遇到,有时我们不是基于导航控制器的切换,但实际开发中,有时需要做成push效果,下面将如何实现push和pop 默认动画效果代码实例:

      一、push默认动画效果

     1    CATransition *transition = [CATransition animation];
     2 
     3     transition.duration = 0.3f;
     4 
     5     transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
     6 
     7     transition.type = kCATransitionPush;
     8 
     9     transition.subtype = kCATransitionFromRight;
    10 
    11     transition.delegate = self;
    12 
    13     [self.contentView.layer addAnimation:transition forKey:nil];
    14 
    15  
    16 
    17     [self.contentView addSubview:self.productDetailController.view];
    18 
    19   

      注:self.contentView是工程中的UIView,self.productDetailController是工程中的controller

            只需要把两者替换成合适的内容即可用

      二、pop默认动画效果

     1   CATransition *transition = [CATransition animation];
     2 
     3     transition.duration = 0.3f;
     4 
     5     transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
     6 
     7     transition.type = kCATransitionPush;
     8 
     9     transition.subtype = kCATransitionFromLeft;
    10 
    11     transition.delegate = self;
    12 
    13     [self.view.superview.layer addAnimation:transition forKey:nil];
    14 
    15  
    16 
    17     [self.view removeFromSuperview];

        说明:.type 设置了主要的页面切换显示形式

                 .subtype 设置了页面的旋转  左右上下

  • 相关阅读:
    字的传送
    mov 寄存器,段寄存器
    c语言中利用三维数组计算成绩总分数
    python中break语句
    c语言中求课程总分、平均分。学生总分及平均分
    python中assert语句
    python中random模块引入随机数
    python中实现列表的倒序排列
    c语言中求两个矩阵的乘积
    python的严格缩进可以避免else悬挂
  • 原文地址:https://www.cnblogs.com/A--G/p/4711664.html
Copyright © 2011-2022 走看看