Ad

IOS9 And InitWithPattern With IPad Pro Causing Repeating Background

- 1 answer

I now upgraded to iPad Pro simulator for iOS9 and now I am getting a repeating background. Is there something new I must do in order to get the image to correctly expand on iPad Pro. My image sizes dont have a new launch image so I am lost on this.

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

Answer

Try to use the CGImage in background to avoid repeating background.

Objective-C

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

Swift

self.view.layer.contents = UIImage(named:"backgroundImageAsset").CGImage
Ad
source: stackoverflow.com
Ad