At the moment from the Apple documentation, properties of the overlay appear to be limited.
At the moment from the Apple documentation, properties of the overlay appear to be limited.
What about on orientation change? Delegate method isn't called when the orientation changes. If my current view controller has an overlay feels like I should be able to access the frame at anytime...to make sure my content doesn't overlap the overlay? Perhaps something like this?
@interface UIWindowScene (SKOverlay)
@property (nullable,nonatomic,strong,readonly) SKOverlay *presentedOverlay;
@end
@interface SKOverlay (FrameInView)
-(void)overlayFrameConvertedToView:(UIView*)view;
@end
//From my view controller...
-(void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
UIWindowScene *scene = self.view.window.windowScene;
SKOverlay *presentedOverlay = scene.presentedOverlay;
if (presentedOverlay == nil)
{
//No overlay...layout
}
else
{
//overlay is showing...don't place anything inside its rect...
CGRect overlayRect = [presentedOverlay overlayFrameConvertedToView:self.view];
}
}
Why doesn't SKOverlay provide a frame/API to convert its current rect into any arbitrary view in the same window scene? I'm assuming the SKOverlay is being shown in a different UIWindow....showing the SKOverlay doesn't even cause -viewSafeAreaInsetsDidChange to be called. Seems like this object can only be used in the simplest of view controllers.
My workaround is to remove and recreate the SKOverlay on orientation change. Also have to hold the SKOverlayTransitionContext's endFrame in a property to access the current location during other events (like viewDidLayoutSubviews etc.) Feels like this API could be improved.