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服 ...
随机推荐
- 开源--豆瓣小组UWP,已上架应用商店
1.前言 豆瓣小组是我和我老婆都比较喜欢的豆瓣家族里面的一款产品.平时加入了一些小组,偶尔打开看下新鲜的帖子,可以打发一下无聊的时间. 豆瓣小组UWP是我前几周在家里开发的一款windows 10应用 ...
- 流量工程 traffic engineering (TE)
什么是流量工程 流量工程是指根据各种数据业务流量的特性选取传输路径的处理过程.流量工程用于平衡网络中的不同交换机.路由器以及链路之间的负载. [编辑] 流量工程的内容 流量工程在复杂的网络环境中,控制 ...
- XML的解析和保存
1.XML(extensible markup language;XML ) 定义:,可以用来标记数据.定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言. XML语法规范: 标 ...
- linux 定时执行scrapy命令
解决方案: 1.以管理员方式执行命令添加计划 sudo crontab -e 添加: 1 0 * * * sh /home/ubuntu/CRON/cron.sh 2. 重启cron服务 sudo s ...
- 【jQuery EasyUI系列】 创建展开行明细编辑表单的CRUD应用
当切换数据网络格局(datagrid view)到detailview,用户可以展开一行来显示一些行的明细在行下面,这个功能允许您为防止在明细行面板中的编辑表单提供一些合适的布局. 步骤1.在HTML ...
- 【原创】解决jquery在ie中不能解析字符串类型xml结构的xml字符串的问题
$.fn.extend({ //此方法解决了ie中jquery不识别非xml的类型的xml字符串的问题 tony tan findX: function (name) { if (this & ...
- android修改系统时区
动态注册广播接收器必须有实例存在 静态不要实例存在 设置系统时区: AlarmManager mAlarmManager = (AlarmManager)getSystemService(Con ...
- 【BZOJ 3048】【USACO2013 Jan】Cow Lineup 滑块思想
昨天下午想了好久没想出来,果然是很弱,思考能力低下. 用的类似单调队列的思想,维护一个长度为$k+1$的滑块,每次统计下$ans$就可以了 #include<cstdio> #includ ...
- javascript 方法实例
输出对象的属性名称与值 : boj(o){ for(var p in o){ console.log(p + ":" + o[p] + "\n"); } } 构 ...
- C++之再续前缘(二)——类和对象(上)
1.类的构成:数据和函数 public:可以由在类外由类的对象访问 private:只能由类内的成员函数访问 protected:可以由本类的成员函数访问,也可以由本类的派生类的成员函数访问 访问权限 ...



