Search code examples
iossafearealayoutguide

iOS - How to create view inside Safe Area programmatically


I have started using Safe Area after iPhone X with AutoLayout.

Now I want to draw a view from bottom of screen to all other screens and for iPhone X from bottom of safe area.

I have been using self.view.frame.size.height but it creates below safe area because of the obvious reason.

How can I get the safe area ending point so that I can draw the view inside Safe area?

Edit: I am not creating Safe Area Programmatically.


Solution

  • It seems by using self.view.safeAreaInsets.bottom and self.view.safeAreaInsets.top I was able to address my problem.