fix of screenshots of the navigation bar on iOS 26 (#4938)

This commit is contained in:
mark.dev
2026-05-03 09:26:19 +03:00
committed by GitHub
parent b8e1c7ebb1
commit ede3a56ebd
+15 -1
View File
@@ -123,7 +123,21 @@ DTX_DIRECT_MEMBERS
CGFloat scale = window != nil ? window.screen.scale : 0.0;
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, scale);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
BOOL rendered = NO;
if (@available(iOS 26.0, *))
{
// iOS 26 liquid-glass bars (UINavigationBar/UITabBar) and other
// visual-effect views are not captured by CALayer.renderInContext:,
// which skips visual effects and returns blank output. Use
// drawViewHierarchyInRect:afterScreenUpdates:YES so those composite
// correctly. Falls back to renderInContext: if drawing fails (e.g.
// detached views or off-window windows).
rendered = [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
}
if (!rendered)
{
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
}
UIImage *image= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();