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. 我的Logo设计简史

    近日,日本东京奥运会会微因涉嫌抄袭而被弃用的新闻引起设计界的一翻热论.在此我想到自己的LOGO设计,虽说并一定不好看甚至自己看回来都觉得略丑,但 几乎没有过抄袭的念头.有句话说,不想当设计师的程序猿不 ...

  2. 拥抱 HTML5:storage 简介以及使用方法

    前言 storage 其实是个很简单的东西,基本上只要知道 javascript 中对象的概念,然后读完此文,storage 的用法也就了然于胸了. 简单来说,你可以把 storage 想象成是储存在 ...

  3. 网页中三角切边还半透明,现在的设计师越来越牛,css也要跟上啊

    需求 今天在群里看到一个需求,啊这种三角形缺角怎么做啊,还带半透明阴影的. 分析 要实现这个,可以用css做三角,网上找一下代码,像这样. 由于以前没有试过border能不能带透明,所以需要试验一下. ...

  4. SignalR与ActiveMQ结合构建实时通信

    一.概述 本教程主要阐释了如何利用SignalR与消息队列的结合,实现不同客户端的交互 SignalR如何和消息队列交互(暂使用ActiveMQ消息队列) SignalR寄宿在web中和其他Signa ...

  5. android开发------编写用户界面之相对布局

    今天要说的是RelativeLayout.RelativeLayout相对于LinearLayout的主要不同点在于它需要一个参照物. 我们先来看一下官方对这个布局的解释: RelativeLayou ...

  6. 网站移植到linux上后常犯的错误

    常犯的错误 1:gcc库没装或者没装全 表现:没有可用的C编译器 同类错误:提示g++ not found, 解决:出现以上错误,则是因为gcc编译器没装,或者是没装全. 挂载光盘,到Pakeges里 ...

  7. extjs store的操作

    先来个声明,看着不错,贴过来的,没都测试过. Store.getCount()返回的是store中的所有数据记录,然后使用for循环遍历整个store,从而得到每条记录. 除了使用getCount() ...

  8. 开发错误记录5-Failed to sync Gradle project ‘HideTitleDemo’

    今天用Android Studio2.0创建的项目,到Android Studio1.5打开,直接报错: 意思就是内存空间不够,要在gradle.properties 文件中进行内存设置,因为是从高版 ...

  9. SharedPrefernces使用实例讲解

    activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...

  10. javascript 方法实例

    输出对象的属性名称与值 : boj(o){ for(var p in o){ console.log(p + ":" + o[p] + "\n"); } } 构 ...