动画 UINavigationController 的“后退”按钮
我在导航控制器的层次结构中的视图控制器上有一个自定义按钮,按下该按钮时,会弹出可见的视图控制器。
我想使用 UIView 的 transform
属性来设置视图控制器关闭的动画。它有效,但如果我使用“popViewControllerAnimated:YES”,动画的默认左幻灯片仍然存在,尽管我的自定义转换也有效。
如果我设置 popViewControllerAnimated:NO
它根本不会为任何内容设置动画。
我还研究了使用 CATransition,当我将 popViewControllerAnimated 设置为 NO 时,它会起作用,但没有“缩放”效果公共API,我不想使用私有效果。自定义过滤器也不适用于 iPhone,仅适用于 OS X。
所以我想我的问题是:
1) 有没有办法删除默认过渡中的左侧幻灯片,但仍然使用 transform
?
2)有什么方法可以为CATransition
使用自定义过滤器?
3) 如果我使用私有 API 来实现缩放效果,Apple 将我的应用程序扔进拒绝箱的可能性有多大?
有人有我忽略的解决方案吗?
I have a custom button on a view controller in the navigation controller's heirarchy, that when pressed, pops the visible view controller.
I want to use UIView's transform
property to animate the closing of the view controller. It works, but if I use `popViewControllerAnimated:YES', the default left slide of the animation is still there, though my custom transform also works.
If I set popViewControllerAnimated:NO
it doesn't animate anything at all.
I also looked into using CATransition
which works when I have popViewControllerAnimated
set to NO
, but there isn't a "zoom" effect that's part of the public API, and I don't want to use the private effect. Custom filters are also not available for iPhone, only OS X.
So I guess my questions are:
1) Is there a way to remove the the left slide in the default transition yet still have a custom animation using transform
?
2) Some way to use a custom filter for CATransition
?
3) If I use a private API for the zoom effect how likely will Apple toss my app in the rejection bin?
Does anyone have a solution I'm overlooking?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我做了与您描述的类似的事情,即更改 UINavigationController 中视图的弹出和推送的默认动画。
这个想法是禁用对象的默认动画并将其替换为您自己的动画。我为 UINavigationController 创建了一个新类别,并使用了类似于下面的函数。
使用只需使用代码
为了进行推送,只需创建另一个类似的函数并反转动画。
它并不完美,但它有效。当您选择不同的动画类型时,请使用组成导航栏/控制器的不同子视图以使其完美。
我花了相当多的时间才想出这个,所以明智地使用它:)
******** 编辑
尝试用这个替换推送过渡(我自己没有尝试过):
这将弹出,即在达到合适的尺寸之前,视图会变大。使用数组中的值来控制动画的曲线。
I've done something similar to what you describe, i.e. change the default animation for pop and push of view in UINavigationController.
The idea is to disable the default animation for the object and replace it with your own animation. I've created a new category for UINavigationController and used a function similar to the one below.
to use just use the code
In order to do a push just create another similar function and reverse the animation.
It's not perfect but it works. When you choose different animation types play around with the different subviews composing the navigation bar/controller to get it perfect.
Took my quite a white to come up with this, so use it wisely :)
******* EDIT
Try replacing the push transition with this (Didn't try it myself):
This will do a pop in, i.e. the view will be bigger before it settles to the right size. Play with the values in the array to control the curve of the animation.