动画层方向
您好,感谢您查看我的问题。
我有一个仅支持横向(左按钮或右按钮)的应用程序。它以横向左启动。太棒了 - 它以正确的方向启动,甚至可以在横向左右之间正确重新调整视图(我已经自定义了支持的方向方法)。
继续我的问题:我启动应用程序并添加一个视图。我启动一个动画,然后将第一个视图与第二个视图交换(第二个视图与第三个视图交换,等等)。
我的问题是动画不一致。
如果我指定 kCATransitionFromLeft,我的过渡将从顶部或底部滑入(取决于设备的方向)。如果我从 kCATransitionFromRight 指定,我会得到相同的行为。
如果我指定 kCATransitionFromBottom 或 kCATransitionFromTop - 那么过渡会正确显示,新视图从一侧滑入,但是,它源自哪一侧仍然取决于设备的方向。
我希望我的视图始终从右向左滑入。显然我可以使用 kCATransitionFromBottom 或 kCATransitionFromTop 编写 if/then 来实现此目的,但我的想法是必须有一种更简单的方法。
那么,有没有一种简单的方法可以让动画根据方向一致地产生呢?为什么 kCATransitionFromBottom 不总是从底部发起?我该如何开始改变这种行为呢?
感谢您的任何见解。
Hello and thanks for looking at my question.
I have an app that supports landscape orientation only (either left or right button). It launches in landscape-left. Great - it launches in correct orientation, and it even reorients views properly (I've customized the supported orientations method) between landscape left and right.
Moving on to my question: I start the app and add a view. I start an animation and then swap my first view with a second (and a second with a third, etc).
My problem is the animation isn't consistent.
If I specify a kCATransitionFromLeft, my transition slides in from the TOP or the BOTTOM (depending on orientation of device). If I specify from kCATransitionFromRight, I get the same behavior.
If I specify kCATransitionFromBottom or kCATransitionFromTop - then the transition appears correctly with the new view sliding in from the side, however, which side it originates from still depends on the orientation of the device.
I want my view to always slide in from right to left. Obviously I could write an if/then to achieve this using kCATransitionFromBottom or kCATransitionFromTop, but my thought is that there must be an easier way.
So, is there a simple way to have animations originate consistently according to the orientation? Why does a kCATransitionFromBottom not ALWAYS originate from the bottom? How would I even begin to modify this behavior?
Thanks for any insights.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在我正在开发的项目中做同样的事情,动画是通过滑动开始的。唯一的区别是我正在交换 UIImages。
如果您可以发布一些代码,这将会有所帮助,我现在唯一记得的就是检查父视图和交换视图是否正确支持横向视图:
希望这有帮助!
I'm doing the same thing on a project I'm working on, the animation is started with a swipe. The only difference is that I'm swapping UIImages.
It would help if you could post some code, the only thing I remember right now is for you to check if the parent and swapped views correctly supports landscape view:
Hopes this helps!