You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/04/24 20:09:31 UTC
(cordova-plugin-inappbrowser) 01/01: feat(ios): use `UIBarButtonSystemItemClose` since iOS 26
This is an automated email from the ASF dual-hosted git repository.
GitToTheHub pushed a commit to branch pr-ios-use-close-button-since-ios-26
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
commit eae889e37ea8de37422c0c336afcb799660c2466
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Fri Apr 24 22:09:16 2026 +0200
feat(ios): use `UIBarButtonSystemItemClose` since iOS 26
- Since iOS 13 it's possible to use `UIBarButtonSystemItemClose` instead of `UIBarButtonSystemItemDone` which correspond perfectly to a close button. Since `UIBarButtonSystemItemClose` looks akward on iOS 18 and older, because an X inside a round button is shown, instead of a text, the close button is only applied since iOS 26.
Co-authored-by: Copilot <co...@github.com>
---
src/ios/CDVWKInAppBrowser.m | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index 71c1c9a..3a940c7 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -38,6 +38,8 @@
#define IAB_BRIDGE_NAME @"cordova_iab"
+#define kCloseButtonSystemItem (@available(iOS 26.0, *) ? UIBarButtonSystemItemClose : UIBarButtonSystemItemDone)
+
#pragma mark CDVWKInAppBrowser
@implementation CDVWKInAppBrowser
@@ -810,7 +812,9 @@ BOOL isExiting = NO;
// We add our own constraints, they should not be determined from the frame.
self.spinner.translatesAutoresizingMaskIntoConstraints = NO;
- self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
+ self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:kCloseButtonSystemItem
+ target:self
+ action:@selector(close)];
self.closeButton.enabled = YES;
UIBarButtonItem *flexibleSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
@@ -1013,11 +1017,11 @@ BOOL isExiting = NO;
- (void)setCloseButtonTitle:(NSString *)title withColor:(NSString *)colorString atIndex:(int)buttonIndex
{
- // The advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically
- // but, if you want to set this yourself, knock yourself out. (We can't set the title for a system Done button, so we have to create a new one.)
+ // The system Close/Done button title is localized automatically.
+ // If a custom caption is provided, create a title-based button instead.
self.closeButton = nil;
- // Initialize with title if title is set, otherwise the title will be 'Done' localized.
- self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
+ // Initialize with title if set, otherwise use the system-localized Close/Done item.
+ self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:kCloseButtonSystemItem target:self action:@selector(close)];
self.closeButton.enabled = YES;
// If color on closebutton is requested then initialize with that that color, otherwise use initialize with default.
self.closeButton.tintColor = colorString != nil ? [self colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org