【问题标题】:iOS9 and initWithPattern with iPad Pro causing repeating backgroundiOS9 和带有 iPad Pro 的 initWithPattern 导致重复背景
【发布时间】:2015-12-15 04:48:57
【问题描述】:

我现在升级到 iOS9 的 iPad Pro 模拟器,现在我得到一个重复的背景。为了让图像在 iPad Pro 上正确展开,我必须做些什么新的事情吗?我的图片尺寸没有新的启动图片,所以我迷路了。

- (void)addBackgroundImage:(NSString*)imageName {
    UIColor *image = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:imageName]];
    self.view.backgroundColor = image;
}

【问题讨论】:

    标签: ios objective-c xcode background ios9


    【解决方案1】:

    尽量在后台使用CGImage,以避免重复背景。

    目标-C

    self.view.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"backgroundImageAsset"].CGImage);
    

    斯威夫特

    self.view.layer.contents = UIImage(named:"backgroundImageAsset").CGImage
    

    【讨论】:

      猜你喜欢
      • 2014-12-09
      • 1970-01-01
      • 2018-12-03
      • 1970-01-01
      • 2020-12-13
      • 2018-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多