Reputation: 69
I'm using Swift 4, XCode 9. I have an iOS application which has a background image which was set using storyboard. The actual storyboard file is viewed from the frame of reference of an iPhone SE. However, I've never had a problem with the image scaling to bigger phone sizes, except now for iPhone 10. It won't fill the whole screen. How can I fix this? The background is displayed through an image view. I've tried changing the height of the image view both via story board and programmatically with no luck. Again, this only is a problem on iPhone 10.
EDIT: I've somewhat fixed this problem by adding a specific iPhone X Launch Image, but now my components are all shifted to the left
Upvotes: 1
Views: 2233
Reputation: 2388
There are few steps you should be careful.
Step 1: Choose the device iPhone X in Interface builder.
Step 2: Add a full image to the ViewController.
Step 3: Add constraints (Should be all Zero) by selecting the bottom menu.
We all set. If you start adding from iPhone X or later devices, it will automatically adjust the bottom, top, left and right constraints accordingly all the previous devices.
NB: While we adding manual constraints, be aware that the SafeAreaLayout has the first priority than the manual constraints.
Another method (You can use either one depends upon your interest)
Provide leading, trialing, top and bottom constraints to the background image. Then select the bottom constrain, and from the size inspector choose the first item as Superview
I believe this will help somebody. Cheers.
Upvotes: 1
Reputation: 958
iPhone X has a different screen size of 375 × 812 points (1125×2436 pixels). The iPhone X's aspect ratio is approximately 9:19.5 So it is different. Here is Apple's official guide which tells you how to handle images. https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/
Please show us some code or image so that we can solve your problem.
Upvotes: 0