How to get the visible view size in iOS13 when presenting a view controller

Viewed 564

In iOS13, the default way when presenting a view controller was changed to the "sheets/cards" view. As I’m not using auto layout (why not, is not really important and relevant), I rely on getting position of elements based on the frame of the view.

Now, the problem with the new method is, that the view frame doesn’t really reflect the actual content size visible on the screen anymore. E.g. if I have positioned a UIButton at the bottom on the view controller based on the view.frame bottom coordinate, it will be now cut off, as the view is actually moved down in the amount of the nice "sheets/cards" visual indication at the top. The same problem is even more evident in an iPad, where centring another view in the view controllers view will be offset, due to the fact that the default presentation style is now a "sheet" in the middle of the screen.

I’ve currently changed everything to force the full screen version, but it would be nice to use the new fancy design.

Anybody has any idea how to get the actual visible rect/coordinates in the new style without changing things to auto layout?

Full screen presentation Default in iOS13 (iPhone) Default in iOS13 (iPad)

Here are how they look. The "flower" is centered in the view and the X button should not be so close to the bottom or missing completely in the iPad version.

1 Answers

Finally figured it out. As I was setting the positions of items in viewDidLoad, the frame was not calculated correctly, thus resulting things being laid out incorrectly. When resetting the frame and positions in viewDidLoadSubviews, the positions were placed correctly.

Related