You can find top and bottom padding programmatically. I think this will solve your issue.
if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.keyWindow;
CGFloat topPadding = window.safeAreaInsets.top;
CGFloat bottomPadding = window.safeAreaInsets.bottom;
}
Edit: As mentioned in the comments (thanks, @albert-renshaw), the object can't be drawn from viewDidLoad on the first run as UIWindow won't be accessible until after at least one run loop. To bypass this you can do it several ways:
1. Simply move your viewDidLoad code into a new method postViewDidLoad and use:
[self performSelector:@selector(postViewDidLoad) withObject:nil afterDelay:0.0f];
...in the original viewDidLoad method, then UIWindow will be accessible.
OR
2. Enclose creation of your object in
dispatch_async(dispatch_get_main_queue(), ^{
// your code here...
});