APPLE提供了三种storyboard segue的方式:push,modal,custom .

push segue是系统预定义的跳转方式,

为了使其能正常工作,我们还必须加载UINavigationController。

有时候,我们不想看到UINavigation bar,我们可以使用modal segue。

modal segue 的跳转方式有四种:Cover Vertical, Flip Horizontal, Cross Dissolve and Partial Curl。

要是我们想要的跳转方式与这四种方式都不同,我们可以使用自定义跳转方式custom segue。

下面是一个实现custom segue的样例:

1.创建一个UIStoryboardsegue的子类

2.重载-(void)perform 方法

 1 - (void) perform
 2 {
 3     UIViewController *desViewController = (UIViewController *)self.destinationViewController;
 4     
 5     UIView *srcView = [(UIViewController *)self.sourceViewController view];
 6     UIView *desView = [desViewController view];
 7     
 8     desView.transform = srcView.transform;
 9     desView.bounds = srcView.bounds;
     
     if(isLandscapeOrientation)
     {
         if(isDismiss)
         {
             desView.center = CGPointMake(srcView.center.x, srcView.center.y  - srcView.frame.size.height);
         }
         else
         {
             desView.center = CGPointMake(srcView.center.x, srcView.center.y  + srcView.frame.size.height);
         }
     }
     else
     {
         if(isDismiss)
         {
             desView.center = CGPointMake(srcView.center.x - srcView.frame.size.width, srcView.center.y);
         }
         else
         {
             desView.center = CGPointMake(srcView.center.x + srcView.frame.size.width, srcView.center.y);
         }
     }
     
     
     UIWindow *mainWindow = [[UIApplication sharedApplication].windows objectAtIndex:];
     [mainWindow addSubview:desView];
     
     // slide newView over oldView, then remove oldView
     [UIView animateWithDuration:0.3
                      animations:^{
                          desView.center = CGPointMake(srcView.center.x, srcView.center.y);
                          
                          if(isLandscapeOrientation)
                          {
                              if(isDismiss)
                              {
                                  srcView.center = CGPointMake(srcView.center.x, srcView.center.y + srcView.frame.size.height);
                              }
                              else
                              {
                                  srcView.center = CGPointMake(srcView.center.x, srcView.center.y - srcView.frame.size.height);
                              }
                          }
                          else
                          {
                              if(isDismiss)
                              {
                                  srcView.center = CGPointMake(srcView.center.x + srcView.frame.size.width, srcView.center.y);
                              }
                              else
                              {
                                  srcView.center = CGPointMake(srcView.center.x - srcView.frame.size.width, srcView.center.y);
                              }
                          }
                      }
                      completion:^(BOOL finished){
                          //[desView removeFromSuperview];
                          [self.sourceViewController presentModalViewController:desViewController animated:NO];
                      }];

70 }

在viewcontroller中,重载prepareforsegue方法

 1 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 2 {
 3     HorizontalSlideSegue *s = (HorizontalSlideSegue *)segue;
 4     s.isDismiss = NO;
 5     
 6     if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
 7     {
 8         s.isLandscapeOrientation = YES;
 9     }
     else
     {
         s.isLandscapeOrientation = NO;
     }

14 }

3.选择custom segue 设置segue class为:customsegue(我们自定义的类)

4.使用代码方式调用segue:

IOS - Create Push Segue Animation Without UINavigationController的更多相关文章

  1. Xcode6 storyboard new push segue 后的视图控制器没有navigation item bug.

    手动切一下 老的push,再切回来,就会出有了,我想是一个bug. Xcode 6 Segue with UINavigationItem up vote0down votefavorite   I' ...

  2. iOS 核心动画 Core Animation浅谈

    代码地址如下:http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVie ...

  3. 对照 Android 的 Intent 与 iOS StoryBoard 的 Segue - Intent 假设也能添加个prepareForSegue回调就好了

    对照 Android 的 Intent 与 iOS StoryBoard 的 Segue - Intent 假设也能添加个prepareForSegue回调就好了 太阳火神的漂亮人生 (http:// ...

  4. IOS 7 Study - Implementing Navigation with UINavigationController

    ProblemYou would like to allow your users to move from one view controller to the other witha smooth ...

  5. IOS开发-UI学习-UINavigationController(导航控制器)的使用

    UINavigationController是IOS 中常用的功能,基本用法如下: 1.在AppDelegate.m中添加如下代码: #import "AppDelegate.h" ...

  6. iOS开发之Segue

    Storyboard上每一根用来界面跳转的线,都是一个UIStoryboardSegue对象(简称Segue). 每一个Segue对象,都有3个属性: (1)唯一标识 @property (nonat ...

  7. iOS开发之Core Animation

    在IOS中如果使用普通的动画则可以使用UIKit提供的动画方式来实现,如果想实现更复杂的效果,则需要使用Core Animation了. 在Core Animation中我们经常使用的是 CABasi ...

  8. ios 改变push方向,可以把present改为push方式

    - (void)pop{    CATransition* transition = [CATransition animation];    transition.duration = 0.5;   ...

  9. 一步一步实现iOS应用PUSH功能

    1. push原理 iOS push 工作机制可以用下图简要概括 Provider:应用自己的服务器: APNS:Apple Push Notification Service的简称,苹果的PUSH服 ...

随机推荐

  1. DEV winform treelist设置背景图像

    treelist是一个复杂的控件,包括选中行,奇偶行等均可以单独设置显示效果,空白区域上背景图像的代码如下: private void treeList1_CustomDrawEmptyArea(ob ...

  2. Tensorflow学习笔记3:TensorBoard可视化学习

    TensorBoard简介 Tensorflow发布包中提供了TensorBoard,用于展示Tensorflow任务在计算过程中的Graph.定量指标图以及附加数据.大致的效果如下所示, Tenso ...

  3. 3Dmax 创建物体

    扩展基本体-切角长方体: 增加边: 删除边:在边选择模式下, 选择想要删除的边, 按下ctrl+backsapce

  4. 生成短链(网址) ShortUrlLink

    建表 CREATE TABLE [dbo].[ShortUrl]( [Id] [,) NOT NULL, [LongUrl] [nvarchar]() NOT NULL, [BaseUri] [int ...

  5. MATLAB中plot()画图的颜色线型和希腊字母参数设置

    y         黄色           ·             点线      m         粉红           ○             圈线      c          ...

  6. 什么是viewport,为什么需要viewport

    viewport:视口,视觉窗口,显示区域.在显示面积上手机屏幕相对桌面显示器要小很多,在几年前(现在也如此)大部分网站都是为桌面显示器浏览而设计,很少考虑到适应手机屏幕,所以如果用手机浏览大多网站时 ...

  7. The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path。

    项目上右键-->Build Path-->Configuration Build Path -->Add Library -->Server Runtime 选择tomcat

  8. C++ new失败的处理

    我们都知道,使用 malloc/calloc 等分配内存的函数时,一定要检查其返回值是否为“空指针”(亦即检查分配内存的操作是否成功),这是良好的编程习惯,也是编写可靠程序所必需的.但是,如果你简单地 ...

  9. Java--笔记(2)

    11.根据操作系统中的定义:死锁是指在一组进程中的各个进程均占有不会释放的资源,但因互相申请被其他进程所站用不会释放的资源而处于的一种永久等待状态. 死锁的四个必要条件: 1)互斥条件(Mutual ...

  10. ASP.NET杂谈-一切都从web.config说起(2)(ConfigSections详解-上 )

    ConfigSections的结构 首先我们先回顾一下ConfigSections的结构和它子节点的说明,如下: 1: <configSections> 2: <sectionGro ...