IOS - Create Push Segue Animation Without UINavigationController
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的更多相关文章
- Xcode6 storyboard new push segue 后的视图控制器没有navigation item bug.
手动切一下 老的push,再切回来,就会出有了,我想是一个bug. Xcode 6 Segue with UINavigationItem up vote0down votefavorite I' ...
- iOS 核心动画 Core Animation浅谈
代码地址如下:http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVie ...
- 对照 Android 的 Intent 与 iOS StoryBoard 的 Segue - Intent 假设也能添加个prepareForSegue回调就好了
对照 Android 的 Intent 与 iOS StoryBoard 的 Segue - Intent 假设也能添加个prepareForSegue回调就好了 太阳火神的漂亮人生 (http:// ...
- 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 ...
- IOS开发-UI学习-UINavigationController(导航控制器)的使用
UINavigationController是IOS 中常用的功能,基本用法如下: 1.在AppDelegate.m中添加如下代码: #import "AppDelegate.h" ...
- iOS开发之Segue
Storyboard上每一根用来界面跳转的线,都是一个UIStoryboardSegue对象(简称Segue). 每一个Segue对象,都有3个属性: (1)唯一标识 @property (nonat ...
- iOS开发之Core Animation
在IOS中如果使用普通的动画则可以使用UIKit提供的动画方式来实现,如果想实现更复杂的效果,则需要使用Core Animation了. 在Core Animation中我们经常使用的是 CABasi ...
- ios 改变push方向,可以把present改为push方式
- (void)pop{ CATransition* transition = [CATransition animation]; transition.duration = 0.5; ...
- 一步一步实现iOS应用PUSH功能
1. push原理 iOS push 工作机制可以用下图简要概括 Provider:应用自己的服务器: APNS:Apple Push Notification Service的简称,苹果的PUSH服 ...
随机推荐
- 千呼万唤岂出来,写款软件不容易——Visual Entity 2.0 发布
在各位用户不继的催更中,终于完成了这次更新.Visual Entity这个软件发布于 2011年,这个软件完成后,便上班去了,也没有做什么推广工作.所以知道的用户并不多,尽管它是个非常好用.并且免费的 ...
- go println与printf区别
Println 与Printf 都是fmt 包中的公共方法 Println :可以打印出字符串,和变量: Printf : 只可以打印出格式化的字符串,可以输出字符串类型的变量,不可以输出整形变量和整 ...
- 前端 head 中mate 详解
<meta name="viewport" content="width=device-width,height=device-height,initial-sca ...
- eclipse failed to load the jni jvm.dll
问题:打开Eclipse弹出,eclipse failed to load the jni jvm.dll,一般都是本机的JDK与Eclipse位数不等{32-64,64-32} 解决:看本机Java ...
- Bete冲刺第三阶段
Bete冲刺第三阶段 今日工作: web: 检索了各类资料,今日暂时顺利解决了hibernate懒加载异常的问题,采用的凡是也比较简单就是添加了一个OpenSessionInViewFilter的过滤 ...
- Nginx之负载均衡服务器揭秘
Nginx代理服务器, 一次性代理多台后端机器, 利用负载算法, 决定将当前请求传递给某台服务器执行. 有哪些后台服务器?例如微软的IIS,Apache,Nginx 负载算法是什么? 加权轮询. ng ...
- js函数声明
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- Ceph性能优化总结(v0.94)
优化方法论 做任何事情还是要有个方法论的,“授人以鱼不如授人以渔”的道理吧,方法通了,所有的问题就有了解决的途径.通过对公开资料的分析进行总结,对分布式存储系统的优化离不开以下几点: 1. 硬件层面 ...
- “CEPH浅析”系列之六——CEPH与OPENSTACK
在 <"Ceph浅析"系列之二--Ceph概况>中即已提到,关注Ceph的原因之一,就是OpenStack社区对于Ceph的重视.因此,本文将对Ceph在OpenSta ...
- 对C语言中指针的一些新认识
学C语言这么久了,才发现指针不是想象中那么简单,当初根本就没理解指针怎么用! 变量--是由操作系统自动分配存储空间的 指针--手动分配存储空间或指向已有变量的地址 指针中的内容需要手动释放,而变 ...



