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

alexander.pan picture alexander.pan · Sep 13, 2017 · Viewed 8.7k times · Source

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

Answer

Ben Lings picture Ben Lings · Sep 13, 2017

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

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

etc