我现在升级到适用于 iOS9 的 iPad Pro 模拟器,现在我得到了一个重复的背景。为了让图像在 iPad Pro 上正确扩展,我必须做些什么新的事情吗?我的图像尺寸没有新的启动图像,所以我迷失了。
- (void)addBackgroundImage:(NSString*)imageName {
UIColor *image = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:imageName]];
self.view.backgroundColor = image;
}
最佳答案
尽量在后台使用CGImage
,避免后台重复。
objective-C
self.view.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"backgroundImageAsset"].CGImage);
swift
self.view.layer.contents = UIImage(named:"backgroundImageAsset").CGImage
关于iOS9 和 initWithPattern 与 iPad Pro 导致重复背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34281325/