iOS 上方向改变时的非旋转背景图像

发布于 2024-12-21 11:50:18 字数 214 浏览 2 评论 0原文

我正在开发一个 iPhone 应用程序,它允许纵向和横向方向。但是,我在 UIImageView 中有一个背景图像,当方向改变时不应旋转该背景图像。我四处搜寻并尝试了一些选项,但没有找到令人满意的解决方案。我尝试在 willAnimateRotationToInterfaceOrientation: 中使用变换,但它使图像在旋转过程中移动,并且看起来不太好。我希望它保持静止。

任何帮助表示赞赏。

I'm developing an iphone app and it allows for both portrait and landscape orientation. However, I have a background image, in an UIImageView, which should not be rotated when the orientation changes. I've searched around and experimented with some options, but have not found a satisfactory solution. I tried using transforms in willAnimateRotationToInterfaceOrientation: but it makes the image move during rotation, and doesn't look good. I would like it to remain stationary.

Any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

只等公子 2024-12-28 11:50:18

也许尝试这个:

YourAppDelegate *appDel = [UIApplication sharedApplication].delegate;
[appDel.window insertSubview:yourImageView atIndex:appropriateIndex];

因为您的 appDelegate.window 不关心当前的设备方向,所以它可能是一个解决方案。我只是尝试在方法中的appDel.window中添加一个UIImageView

didFinishLaunchingWithOptions

,正如预期的那样,它不会与上面的uiviewcontroller.view一起旋转

当然你也可以尝试addSubview:

Maybe try this:

YourAppDelegate *appDel = [UIApplication sharedApplication].delegate;
[appDel.window insertSubview:yourImageView atIndex:appropriateIndex];

as your appDelegate.window doesn't care about the current device orientation it might work out as a solution. I just tried adding a UIImageView to the appDel.window in the

didFinishLaunchingWithOptions

method, and as expected, it does not rotate with the above uiviewcontroller.view

Of course you could also try addSubview:

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