gpt4 book ai didi

ios - 自动旋转背景图像 : How to get rid of tiling effect? 最佳实践?

转载 作者:行者123 更新时间:2023-11-29 11:09:55 25 4
gpt4 key购买 nike

我有这段代码可以在 iPad 旋转期间更改背景图像:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if (![SysConfig isPhone]) { // Only need to worry about this for the iPad
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
if ([SysConfig isRetina]) {
if (UIInterfaceOrientationIsLandscape(fromInterfaceOrientation)) {
[[self view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Default-Portrait@2x~ipad.png"]]];
} else {
[[self view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Default-Landscape@2x~ipad.png"]]];
}
// retina display above, regular below
} else {
\\ Same thing but for low res display
}
}
}
}

它工作正常,只是有一小段时间你会看到原始背景图像平铺在新旋转的设备上,然后它旋转并移动到适合新方向的新图像,所以它不会平铺.我想摆脱平铺视觉效果。

我从 SO 上的阅读中了解到,我可能会通过某种动画隐藏平铺(交叉淡入淡出两个图像,或者缩小旧图像并在旋转发生时将其平滑地扩展到新图像)。但我也不确定我是否在正确的地方这样做,因为我已经看到涉及 viewDidAppear viewWillAppear willAnimateRotationToInterfaceOrientation 等的方法.

两个问题:

  1. 我能否通过简单地将此代码(可能会稍作修改)移动到不同的方法(可能会影响效果的时间)来避免这种平铺效果?
  2. 如果我必须制作更精细的动画,我应该使用哪种方法?任何指向示例的指针?

谢谢。我读了很多书,但似乎有很多方法可以使它几乎正确,如果有人对最佳实践发表评论,我将不胜感激。

最佳答案

解决方案:除了交换 Portrait 和 Landscape 的实异常(exception),我将相同的代码放入 willAnimateRotationToInterfaceOrientation 并解决了平铺问题。

关于ios - 自动旋转背景图像 : How to get rid of tiling effect? 最佳实践?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12022994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com