@@ -17,10 +17,10 @@ Licensed to the Apache Software Foundation (ASF) under one
17
17
under the License.
18
18
*/
19
19
20
+ #import < TargetConditionals.h>
20
21
#import < AVFoundation/AVFoundation.h>
21
22
#import < Foundation/Foundation.h>
22
23
#import < WebKit/WebKit.h>
23
- #import < objc/message.h>
24
24
25
25
#import < Cordova/CDVAppDelegate.h>
26
26
#import < Cordova/CDVPlugin.h>
@@ -373,6 +373,30 @@ -(void)viewWillAppear:(BOOL)animated
373
373
-(void )viewDidAppear : (BOOL )animated
374
374
{
375
375
[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
+
376
400
[[NSNotificationCenter defaultCenter ] postNotification: [NSNotification notificationWithName: CDVViewDidAppearNotification object: nil ]];
377
401
}
378
402
0 commit comments