动画层方向

发布于 2024-09-11 03:58:30 字数 635 浏览 9 评论 0原文

您好,感谢您查看我的问题。

我有一个仅支持横向(左按钮或右按钮)的应用程序。它以横向左启动。太棒了 - 它以正确的方向启动,甚至可以在横向左右之间正确重新调整视图(我已经自定义了支持的方向方法)。

继续我的问题:我启动应用程序并添加一个视图。我启动一个动画,然后将第一个视图与第二个视图交换(第二个视图与第三个视图交换,等等)。

我的问题是动画不一致。

如果我指定 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扎心 2024-09-18 03:58:30

我在我正在开发的项目中做同样的事情,动画是通过滑动开始的。唯一的区别是我正在交换 UIImages。

如果您可以发布一些代码,这将会有所帮助,我现在唯一记得的就是检查父视图和交换视图是否正确支持横向视图:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
        interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        return YES;
    }
    return NO;
}

希望这有帮助!

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:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
        interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        return YES;
    }
    return NO;
}

Hopes this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文