How to make a compatible existing application for iPhone X

We have an application with 6-8 screens, which was developed by Swift 3.2. And I use class classes (Auto Resize) without using autorun for all devices that work fine.

But now we want to make it compatible with the iPhone X device.

While we are testing the application on the iPhone X, Subviews has a lot of problems on top, bottom and even the center of the screen.

I saw several forums that said, “Use the Adaptive Sage Guide” in the Story Board UI files, and the problem will be resolved. But, the Event I tried it, there are still many gaps and problems coming from the bottom and top when testing the application with iPhone X.

So, how to make it compatible with iPhone X with my existing code, do I need to change everything programmatically for below iPhone X and iPhone X,or is there anything there?

Can anyone suggest me how to do this.

Note. We are using Xcode 9.2

enter image description here

enter image description here

enter image description here

+4
source share
2 answers

This is not just a thing for the iPhone X, but also iOS 11. iOS 11 introduces a new insertion customization API that devalues ​​most (maybe all?) Of what preceded it. And with the physical design of the iPhone X, more attention is required to safe areas.

So get used to writing:

if #available(iOS 11.0, *) {

    // new iOS 11 syntax
    someView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true

} else {

    // pre-iOS 11 syntax
    someView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor).isActive = true

}

the is safeAreaLayoutGuidenow a property of the presentation itself and more intuitive, IMO. Additional examples of the new API syntax:

someView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
someView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
someView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true

And if you are interested in getting the insertion values:

if #available(iOS 11.0, *) {
    someViewAnchor.constant = view.safeAreaInsets.bottom
} else {
    someViewAnchor.constant = bottomLayoutGuide.length
}

, , , - . https://www.hackingwithswift.com/articles/12/how-to-update-your-app-design-for-iphone-x

0

Safe Area Guides , , , superiew.top superview.bottom Safe Guide the superview Safe Area >

enter image description here

0

Source: https://habr.com/ru/post/1691444/


All Articles