如何在景观中为 iPad 定义资产

How to define an asset for iPad in landscape

我第一次将 iPhone 应用程序改编为 iPad。我很高兴在制作 iPad 的肖像版时看到资产真的很强大。现在我正在制作横向版本,我意识到我的一些图像需要专门为横向制作。

我不知道该怎么做。启动图像有横向变化,但图像集没有。

如何在我的图像集中添加风景变化?

此致。

您可以创建一个 iPad-only xib

即MainView.xib会变成MainView~ipad.xib

我不确定 xcassets 中是否有允许您执行此操作的设置,但这里有一些策略:

9 切片你的图片

UIImage *initialImage = [UIImage imageNamed:@"someImage"];
UIImage *nineSlicedImage = [initialImage  resizableImageWithCapInsets:UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0)];
[self.myImageView setImage:nineSlicedImage]

在运行时设置正确的图像

您可以使用

[[UIDevice currentDevice] orientation]

检查您当前的方向

正确设置 ImageView 模式 在 .xib 或 .storyboard 中,您可以将图像视图的模式设置为 center/left/right/aspect fit/ aspect fill etc

记得将图像视图设置为裁剪子视图,否则图像可以无视框架显示