iOS9 和 initWithPattern 与 iPad Pro 导致重复背景

标签 ios objective-c xcode background ios9

我现在升级到适用于 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/

相关文章:

objective-c - 使用主线程的队列从主线程Dispatch_sync没用吗?

iphone - 比较两个 UITextField

objective-c - 从音频文件中获取专辑封面、歌曲名称、专辑名称和艺术家姓名

objective-c - NSUserDefaults 写在 -applicationWillTerminate : do not take effect; Why?

ios - 在 Swift 中使用 commitEditingStyle 动态删除 UITable 部分

ios - 检查 UITextfield 只有字母没有数值

jquery - 从 iOS 上的 PhoneGap 到服务器上的 PHP 的 "Post"和 "GET"请求不起作用

ios - 在花栗鼠中计算力、速度和距离

iphone - iOS 6 NSDateFormatter stringFromDate : empty day of week

objective-c - 从 UI 中删除图像