Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get safe area top,bottom,right,left value in iOS?

Tags:

ios

ios11

Xcode iOS how to get safe area top ,bottom ,right ,left value like this -> How to get height of topLayoutGuide?

// Inside your viewController
self.topLayoutGuide.length
like image 310
alexander.pan Avatar asked Sep 13 '17 15:09

alexander.pan


People also ask

What is safe area in iPhone?

The safe area defines the area within a view that isn't covered by a navigation bar, tab bar, toolbar, or other views a view controller might provide. iPhone.

How do I disable safe area layout guide?

You can disable safe area layout guide from storyboard for particular view controller. Select View Controller -> File Inspector (first tab) -> Use safe area layout guides (uncheck the checkbox).

What is safe area in storyboard?

Safe areas help you place your views within the visible portion of the overall interface. UIKit-defined view controllers may position special views on top of your content. For example, a navigation controller displays a navigation bar on top of the underlying view controller's content.


1 Answers

The safe area insets is a UIEdgeInsets struct. You can access the components like this:

 view.safeAreaInsets.left
 view.safeAreaInsets.right
 view.safeAreaInsets.top
 view.safeAreaInsets.bottom

etc

like image 102
Ben Lings Avatar answered Oct 19 '22 05:10

Ben Lings