[Swift] Get the height of Safe Area

I wanted to get the height of the Safe Area, so I looked it up.

Safe Area height

python


//Safe Area at the top
let safeAreaTop = self.view.safeAreaInsets.top
print(safeAreaTop)

//Safe Area at the bottom
let safeAreaBottom = self.view.safeAreaInsets.bottom
print(safeAreaBottom)

By the way

At the time of viewDidLoad, the value of SafeArea could not be acquired, so it seems better to acquire it at viewWillLayoutSubviews.

Recommended Posts

[Swift] Get the height of Safe Area
[Swift] Get the number of steps with CMP edometer
[Swift] How to get the document ID of Firebase
[Swift] Get the timing when the value of textField is changed
[Swift] Get the current time numerically
The basic basis of Swift dialogs
Get the ID of automatic numbering
[Swift] How to dynamically change the height of the toolbar on the keyboard
[Swift5] How to get an array and the complement of arrays
[Swift UI] How to get the startup status of the application [iOS]
Get the result of POST in Java
Automatically adjust the height of Xib files
[Java] Get the day of the specific day of the week
[Swift] Termination of the program by assertion
[Swift] Change the color of SCN Node
The basic basis of Swift custom cells
[Swift] How to get the number of elements in an array (super basic)
How to get the ID of a user authenticated with Firebase in Swift
How to get today's day of the week
[Java] How to get the authority of the folder
[Swift] Termination of the program by the fatalError function
[Swift] Use Swity JSON to easily get information from JSON data of the fortune-telling API
Get the URL of the HTTP redirect destination in Java
[Kotlin] Get the argument name of the constructor by reflection
Is drainTo of LinkedBlockingQueue safe? I followed the source
[Grails] About the setting area and the setting items of application.yml
[Java] How to get the maximum value of HashMap
[Java] Get the file in the jar regardless of the environment
[Swift] This is the solution! Illustration of Delegate implementation
[Android] How to get the setting language of the terminal
Ruby, Nokogiri: Get the element name of the selected node
Find the approximate value of log (1 + x) in Swift
[Rails] How to get the contents of strong parameters
How to judge the click of any area of the image
I can't get out of the Rails dbconsole screen
Get the URL of the HTTP redirect destination in Ruby
Automatically set the width and height of the UI Label
The world of clara-rules (2)
[Swift5] How to analyze complex JSON and get the index of the element that satisfies the condition
Judgment of the calendar
The world of clara-rules (4)
The world of clara-rules (1)
The world of clara-rules (3)
The world of clara-rules (5)
The idea of quicksort
The idea of jQuery
Get the object name of the instance created by the new operator
Now, I understand the coordinate transformation method of UIView (Swift)
Get to the abbreviations from 5 examples of iterating Java lists
[Swift] I tried to implement the function of the vending machine
[Swift] Lightly introduce the logic of the app that passed the selection
How to get the longest information from Twitter as of 12/12/2016
Get only the ID of the container specified by docker ps
Automatically adjust the height of the WebView dialog with the size of the content
[jsoup] How to get the full amount of a document