ios开发 push是什么ios push动画自下而上

问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
默认的UINavigationController push和pop的默认动画都是左右滑动推出,我的应用要求这种界面切换的动画效果复杂一点,大概有这么几个:更快的左右推出,默认是0.3秒,我需要快一倍带抖动的左右推出水平翻转纸张翻页效果但是这些切换都要放在NavigationController里做管理,怎么实现,求个思路
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
1. 如果楼主想要使用UINavigationController中的view controller stack,并且还想要同时自定义push、pop的动画效果,基本上是不可能的。原因在于想要使用view controller stack,就无法躲开
pushViewController:animated:这个方法,而一旦使用pushViewController:animated:,UINavigationController就会强制将要推入的viewController的frame设为当前可视区域的frame,从而断绝一切想要自定义动画的后路,例如如下代码,是不会产生任何效果的:UINavigationController+CustomAnimation.h@interface UINavigationController (CustomAnimation)
- (void)customPushViewController:(UIViewController *)viewC
@endUINavigationController+CustomAnimation.m#import &UINavigationController+CustomAnimation.h&
- (void)customPushViewController:(UIViewController *)viewController
viewController.view.frame = (CGRect){0, -viewController.view.frame.size.height, viewController.view.frame.size};
[self pushViewController:viewController animated:NO];
[UIView animateWithDuration:.15f
animations:^{
viewController.view.frame = (CGRect){0, 0, self.view.bounds.size};
}2. 如果仅仅是想添加自定义的push、pop动画,而不使用view controller stack,那么,如下代码就可以实现一个从上到下的push效果:UINavigationController+CustomAnimation.h文件同上。UINavigationController+CustomAnimation.m#import &UINavigationController+CustomAnimation.h&
- (void)customPushViewController:(UIViewController *)viewController
viewController.view.frame = (CGRect){0, -viewController.view.frame.size.height, viewController.view.frame.size};
[self.topViewController.view addSubview:viewController.view];
[UIView animateWithDuration:.15f
animations:^{
viewController.view.frame = (CGRect){0, 0, self.view.bounds.size};
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
虽然基于navctrl,但是你可以不用navctrl push的方法,可以用viewctrl的presentModalViewController。至于速度的话,这些系统的默认都是0.3s,动画方式也就是系统默认的几个。
如果需要各种自定义动画,能自定义动画的是view,给个例子,供楼主参考下。
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
CATransition* transition = [CATransition animation];
transition.type = kCATransitionP//可更改为其他方式
transition.subtype = kCATransitionFromL//可更改为其他方式
transition.duration=0.15;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:viewController animated:YES];
同步到新浪微博
分享到微博?
Hi,欢迎来到 SegmentFault 技术社区!⊙▽⊙ 在这里,你可以提出编程相关的疑惑,关注感兴趣的问题,对认可的回答投赞同票;大家会帮你解决编程的问题,和你探讨技术更新,为你的回答投上赞同票。
明天提醒我
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
扫扫下载 Apppush自定义动画 - 开源中国社区
当前访客身份:游客 [
当前位置:
发布于 日 17时,
/baishiyun/ViewControllerAnimation/tree/master
代码片段(1)
1.&[代码]push自定义动画&&&&
Skip to content
This repository
@baishiyun baishiyun
baishiyun/ViewControllerAnimation
ViewControllerAnimation/ViewControllerAnimation/ViewController.m
@baishiyun baishiyun 28 minutes ago 自定义Push转场动画
1 contributor
72 lines (60 sloc) 2.616 kb
ViewController.m
ViewControllerAnimation
Created by mac on 15/5/26.
Copyright (c) 2015年 BSY. All rights reserved.
#import "ViewController.h"
#import "TwoViewController.h"
@interface ViewController ()&UINavigationControllerDelegate,UIViewControllerTransitioningDelegate&
@property(nonatomic,strong)TwoViewController*
@property(nonatomic,strong)UIViewController *currentViewC;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"第一页";
self.view.backgroundColor = [UIColor grayColor];
self.Animator = [[BSYAnimator alloc]init];
self.TransitionAnimator = [[BSYTransitionAnimator alloc]init];
UIButton *button
= [UIButton buttonWithType: UIButtonTypeCustom];
[button setFrame:CGRectMake(100, 100, 100, 100)];
[button setTitle:@"Push" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self.view addSubview:button];
[button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
TwoViewController *two = [[TwoViewController alloc]init];
self.two =
self.navigationController.delegate =
two.transitioningDelegate =
two.modalPresentationStyle = UIModalPresentationC
[self addChildViewController:two];
self.currentViewController =
-(void)buttonClick
[self.navigationController pushViewController:self.two animated:YES];
#pragma mark - UINavigationControllerDelegate iOS7新增的2个方法
// 动画特效
- (id&UIViewControllerAnimatedTransitioning&) navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
if (operation == UINavigationControllerOperationPush) {
return self.A
#pragma mark - Transitioning Delegate (Modal)
-(id&UIViewControllerAnimatedTransitioning&)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
self.TransitionAnimator.animationType = AnimationTypeP
return self.TransitionA
-(id&UIViewControllerAnimatedTransitioning&)animationControllerForDismissedController:(UIViewController *)dismissed
self.TransitionAnimator.animationType = AnimationTypeD
return self.TransitionA
Status API Training Shop Blog About
(C) 2015 GitHub, Inc. Terms Privacy Security Contact
开源中国-程序员在线工具:
相关的代码(545)
[Objective-C]
[Objective-C]
[Objective-C]
[Objective-C]
[Objective-C]
[Objective-C]
[Objective-C]
[Objective-C]
[Objective-C]
[Objective-C]
怎么看obj-c都是反人类的语言
开源从代码分享开始
xxxxxyyyyy的其它代码主题 : pushViewController动画效果欠佳,不知道是不是我代码原因
级别: 侠客
可可豆: 436 CB
威望: 436 点
在线时间: 78(时)
发自: Web Page
来源于&&分类
pushViewController动画效果欠佳,不知道是不是我代码原因&&&
当点击表格行,进行页面跳转的时候,界面从右往左推,发现效果很差,还好手速快,截到了个效果图
图片:QQ.png
级别: 精灵王
发帖: 3023
可可豆: 3353 CB
威望: 3331 点
在线时间: 4655(时)
发自: Web Page
被推入的控制器的视图是不可见的吧,例如是透明的。。。
级别: 侠客
可可豆: 436 CB
威望: 436 点
在线时间: 78(时)
发自: Web Page
回 1楼(noah1985) 的帖子
果然加个颜色就ok了,控制器的视图默认的背景色是透明的?
级别: 精灵王
发帖: 3023
可可豆: 3353 CB
威望: 3331 点
在线时间: 4655(时)
发自: Web Page
代码创建的话的确,xib的话是白色。
级别: 新手上路
可可豆: 4 CB
威望: 4 点
在线时间: 39(时)
发自: Web Page
如果不添加颜色,默认是clear color。push的时候会在第二个视图完全加载后变成第二个controller,方法就是在第二个视图添加backgroundcolor,就可以解决了
级别: 骑士
可可豆: 515 CB
威望: 515 点
在线时间: 327(时)
发自: Web Page
另外告诉楼主一个调试动画的技巧模拟器有个功能是慢放动画在模拟器的debug菜单第一项,默认快捷键是command + T
级别: 骑士
UID: 300379
可可豆: 889 CB
威望: 795 点
在线时间: 260(时)
发自: Web Page
看就是透明背景的原因,果断是这样的
级别: 新手上路
可可豆: 15 CB
威望: 15 点
在线时间: 83(时)
发自: Web Page
哈哈,这贴帮了大忙,感谢
级别: 骑士
UID: 131039
可可豆: 707 CB
威望: 659 点
在线时间: 262(时)
发自: Web Page
赞。。。。
级别: 新手上路
UID: 397790
可可豆: 148 CB
威望: 114 点
在线时间: 273(时)
发自: Web Page
现在 我也遇到这样类似的问题了,设置了背景色还是有问题,求好心大神解答
等待稳稳幸福的日子~~
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版鏌ョ湅: 4098|鍥炲?: 0
UID锛

我要回帖

更多关于 ios 自定义push动画 的文章

 

随机推荐