@@ -17,10 +17,10 @@ Licensed to the Apache Software Foundation (ASF) under one
1717 under the License.
1818 */
1919
20+ #import < TargetConditionals.h>
2021#import < AVFoundation/AVFoundation.h>
2122#import < Foundation/Foundation.h>
2223#import < WebKit/WebKit.h>
23- #import < objc/message.h>
2424
2525#import < Cordova/CDVAppDelegate.h>
2626#import < Cordova/CDVPlugin.h>
@@ -373,6 +373,30 @@ -(void)viewWillAppear:(BOOL)animated
373373-(void )viewDidAppear : (BOOL )animated
374374{
375375 [super viewDidAppear: animated];
376+
377+ #if TARGET_OS_MACCATALYST
378+ BOOL hideTitlebar = [self .settings cordovaBoolSettingForKey: @" HideDesktopTitlebar" defaultValue: NO ];
379+ if (hideTitlebar) {
380+ UIWindowScene *scene = self.view .window .windowScene ;
381+ if (scene) {
382+ scene.titlebar .titleVisibility = UITitlebarTitleVisibilityHidden;
383+ scene.titlebar .toolbar = nil ;
384+ }
385+ } else {
386+ // We need to fix the web content going behind the title bar
387+ self.webView .translatesAutoresizingMaskIntoConstraints = NO ;
388+ [self .webView.topAnchor constraintEqualToAnchor: self .view.safeAreaLayoutGuide.topAnchor].active = YES ;
389+ [self .webView.leadingAnchor constraintEqualToAnchor: self .view.leadingAnchor].active = YES ;
390+ [self .webView.trailingAnchor constraintEqualToAnchor: self .view.trailingAnchor].active = YES ;
391+ [self .webView.bottomAnchor constraintEqualToAnchor: self .view.bottomAnchor].active = YES ;
392+
393+ if ([self .webView respondsToSelector: @selector (scrollView )]) {
394+ UIScrollView *scrollView = [self .webView performSelector: @selector (scrollView )];
395+ scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
396+ }
397+ }
398+ #endif
399+
376400 [[NSNotificationCenter defaultCenter ] postNotification: [NSNotification notificationWithName: CDVViewDidAppearNotification object: nil ]];
377401}
378402
0 commit comments