iOS development-use safe area to match iphone X

Source: Internet
Author: User

Recently the adaptation of the iphone x, found some rules, the overall adaptation is very simple

The status bar at the top of the iphone X is 44px from the top of the security zone, and the other iphone is 20px,

The IPhone x security Zone is 34px from the bottom height

Added safe area to Xcode9

Let's get to the bottom.

Safearealayoutguide

First, let's see what Safearealayoutguide is.


Looks complicated, in fact very simple, I summed up a few points:

    1. It is a read-only property of UIView, which means that all UIView objects have and are created by the system to help us
    2. It inherits Uilayoutguide, and layoutframe means it can represent an area.
    3. The area it represents avoids all of the parent view, such as the navigation bar, Tabbar, or other potentially blocking your UIView object display, meaning that your view object can be laid out relative to the safelayoutguide of another view without worrying about her being blocked by weird things.
    4. For the safearealayoutguide of the controller's view, his area also avoids statusbar or other things that might block the view display, and we can even use the Additionalsafeareainsets property of the controller, To specify additional inset
    5. If the view is entirely within the security area of the parent view, or if the view is not on the viewing level or on the screen, then the Safearealayoutguide area of the view is actually as large as the view itself

Safearealayoutguide is a relatively abstract concept, for the sake of understanding, we can think of safearealayoutguide as a "view", this "view" system automatically helps us adjust its bounds, Let it not be blocked by a variety of strange things, including the fringe area of the iphone x and the bottom of a bar area, you can think of this "view" will be able to fully display all the content.

The following green section is the Safearealayoutguide area of the current controller view
iphone x vertical Screen safearealayoutguide bounds


IPhone x Horizontal screen safearealayoutguide bounds


iOS development-use safe area to match iphone X

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.