Xcode 4.5 background image iPhone 4, 4s, 5

后端 未结 3 2090
轻奢々
轻奢々 2021-02-04 18:29

I have in my viewController.m written the background code:

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@\"image.png\"]];
         


        
3条回答
  •  不要未来只要你来
    2021-02-04 19:23

    if you are trying to use [UIImage imageNamed:@"image.png"] and expect image-568h@2x.png to be picked automatically from the bundle for iPhone 5, it will not work. Automatic picking works only for iPhone 4 and 4S.

    Only the Default image named as Default-568h@2x.png will be picked automatically in iPhone 5.

    for normal images, if you have separate image for iPhone 5, try using this code

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    if (screenBounds.size.height == 568) {
        // code for 4-inch screen
    } else {
        // code for 3.5-inch screen
    }
    

提交回复
热议问题