@@ -1756,33 +1756,47 @@ - (CGRect)defaultFrameForBottomDockingView
17561756{
17571757 CGRect toolbarBarFrame = self.toolbar .frame ;
17581758
1759- CGFloat bottomSafeAreaHeight = self. view . safeAreaInsets . bottom ;
1760- if ([ NSStringFromClass ( self .nonMemoryLeakingPresentationController.class) containsString: @" Preview " ] == NO )
1759+ CGFloat bottomSafeAreaHeight = 0.0 ;
1760+ if (unavailable (iOS 18.0 , *) )
17611761 {
1762- bottomSafeAreaHeight -= self.view .window .safeAreaInsets .bottom ;
1762+ bottomSafeAreaHeight = self.view .safeAreaInsets .bottom ;
1763+ if ([NSStringFromClass (self .nonMemoryLeakingPresentationController.class) containsString: @" Preview" ] == NO )
1764+ {
1765+ bottomSafeAreaHeight -= self.view .window .safeAreaInsets .bottom ;
1766+ }
17631767 }
1764-
17651768 toolbarBarFrame.origin = CGPointMake (toolbarBarFrame.origin .x , self.view .bounds .size .height - (self.isToolbarHidden ? 0.0 : toolbarBarFrame.size .height ) - bottomSafeAreaHeight);
17661769
17671770 return toolbarBarFrame;
17681771}
17691772
17701773- (UIEdgeInsets)insetsForBottomDockingView
17711774{
1772- if (self. presentingViewController != nil && [ NSStringFromClass ( self .nonMemoryLeakingPresentationController.class) containsString: @" Preview " ] )
1775+ if (@ available (iOS 18.0 , *) )
17731776 {
1774- return UIEdgeInsetsZero;
1777+ CGFloat offset = 0 ;
1778+
1779+ if (UIDevice.currentDevice .userInterfaceIdiom == UIUserInterfaceIdiomPad)
1780+ {
1781+ static auto key = LNPopupHiddenString (" _backgroundView.bounds" );
1782+ if ([[self .toolbar valueForKeyPath: key] CGRectValue ].size .height < (self.toolbar .bounds .size .height + self.view .safeAreaInsets .bottom ))
1783+ {
1784+ // Something in UIKit reports safe area insets incorrectly on iPadOS. This is a workaround for this issue.
1785+ offset -= 5 ;
1786+ }
1787+ }
1788+
1789+ return UIEdgeInsetsMake (0 , 0 , self.view .safeAreaInsets .bottom + offset, 0 );
17751790 }
1776-
1777- CGFloat offset = 0 ;
1778-
1779- if (UIDevice.currentDevice .userInterfaceIdiom == UIUserInterfaceIdiomPad && self.view .superview .safeAreaInsets .bottom > 0 && ([self _ln_isObjectFromSwiftUI ] || self.splitViewController != nil ))
1791+ else
17801792 {
1781- // Something in SwiftUI reports safe area insets incorrectly on iPadOS. This is a workaround for this issue.
1782- offset -= 5 ;
1793+ if (self.presentingViewController != nil && [NSStringFromClass (self .nonMemoryLeakingPresentationController.class) containsString: @" Preview" ])
1794+ {
1795+ return UIEdgeInsetsZero;
1796+ }
1797+
1798+ return UIEdgeInsetsMake (0 , 0 , MAX (self.view .superview .safeAreaInsets .bottom , self.view .window .safeAreaInsets .bottom ), 0 );
17831799 }
1784-
1785- return UIEdgeInsetsMake (0 , 0 , MAX (self.view .superview .safeAreaInsets .bottom , self.view .window .safeAreaInsets .bottom ) + offset, 0 );
17861800}
17871801
17881802+ (void )load
0 commit comments