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/02/27 11:51:35 UTC
(cordova-plugin-inappbrowser) branch pr-ios-style-address-label created (now ea19395)
This is an automated email from the ASF dual-hosted git repository.
manuelbeck pushed a change to branch pr-ios-style-address-label
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
at ea19395 fix(ios): propery styling of address label
This branch includes the following new commits:
new ea19395 fix(ios): propery styling of address label
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
(cordova-plugin-inappbrowser) 01/01: fix(ios): propery styling of address label
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
manuelbeck pushed a commit to branch pr-ios-style-address-label
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
commit ea19395e898e561c2deac571a7a8058265e4053d
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Fri Feb 27 12:51:27 2026 +0100
fix(ios): propery styling of address label
- Add background view for address label, so the address label can have paddings when a background is set
- Add semi-transparent background with round corners
- Add margins to the address background
Generated-By: GPT-5, XCode 26
---
src/ios/CDVWKInAppBrowser.h | 1 +
src/ios/CDVWKInAppBrowser.m | 64 ++++++++++++++++++++++++++++++++-------------
2 files changed, 47 insertions(+), 18 deletions(-)
diff --git a/src/ios/CDVWKInAppBrowser.h b/src/ios/CDVWKInAppBrowser.h
index a2f0b95..9867ac0 100644
--- a/src/ios/CDVWKInAppBrowser.h
+++ b/src/ios/CDVWKInAppBrowser.h
@@ -67,6 +67,7 @@ typedef NSDictionary CDVSettingsDictionary;
@property (nonatomic, strong) IBOutlet WKWebView *webView;
@property (nonatomic, strong) IBOutlet WKWebViewConfiguration *configuration;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *closeButton;
+@property (nonatomic, strong) IBOutlet UIView *addressBackgroundView;
@property (nonatomic, strong) IBOutlet UILabel *addressLabel;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *backButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *forwardButton;
diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index 3c72092..fa28f94 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -749,12 +749,23 @@ BOOL isExiting = NO;
// We add our own constraints, they should not be determined from the frame.
self.toolbar.translatesAutoresizingMaskIntoConstraints = NO;
+ // Background view for address label
+ self.addressBackgroundView = [[UIView alloc] init];
+ self.addressBackgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2];
+ self.addressBackgroundView.layer.cornerRadius = 15.0;
+ // Don't draw any content that would be outside the view’s rectangular bounds
+ self.addressBackgroundView.clipsToBounds = YES;
+ [self.view addSubview:self.addressBackgroundView];
+ // We add our own constraints, they should not be determined from the frame.
+ self.addressBackgroundView.translatesAutoresizingMaskIntoConstraints = NO;
+
self.addressLabel = [[UILabel alloc] init];
self.addressLabel.adjustsFontSizeToFitWidth = NO;
self.addressLabel.alpha = 1.000;
self.addressLabel.backgroundColor = [UIColor clearColor];
self.addressLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
self.addressLabel.clearsContextBeforeDrawing = YES;
+ // Don't draw any content that would be outside the view’s rectangular bounds
self.addressLabel.clipsToBounds = YES;
self.addressLabel.contentMode = UIViewContentModeScaleToFill;
self.addressLabel.enabled = YES;
@@ -775,7 +786,7 @@ BOOL isExiting = NO;
self.addressLabel.textAlignment = NSTextAlignmentLeft;
self.addressLabel.textColor = [UIColor colorWithWhite:1.000 alpha:1.000];
self.addressLabel.userInteractionEnabled = NO;
- [self.view addSubview:self.addressLabel];
+ [self.addressBackgroundView addSubview:self.addressLabel];
// We add our own constraints, they should not be determined from the frame.
self.addressLabel.translatesAutoresizingMaskIntoConstraints = NO;
@@ -875,12 +886,22 @@ BOOL isExiting = NO;
[self.toolbar.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor]
]];
- // Address label horizontal constraints
+ // Address background horizontal constraints with margin
[NSLayoutConstraint activateConstraints:@[
// Left to safe area for proper layout on landscape
- [self.addressLabel.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:5.0],
+ [self.addressBackgroundView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor
+ constant:15.0],
// Right to safe area for proper layout on landscape
- [self.addressLabel.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor constant:-5.0]
+ [self.addressBackgroundView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor
+ constant:-15.0]
+ ]];
+
+ // Constrain Address label inside Address background view with padding
+ [NSLayoutConstraint activateConstraints:@[
+ [self.addressLabel.topAnchor constraintEqualToAnchor:self.addressBackgroundView.topAnchor constant:10.0],
+ [self.addressLabel.bottomAnchor constraintEqualToAnchor:self.addressBackgroundView.bottomAnchor constant:-10.0],
+ [self.addressLabel.leadingAnchor constraintEqualToAnchor:self.addressBackgroundView.leadingAnchor constant:10.0],
+ [self.addressLabel.trailingAnchor constraintEqualToAnchor:self.addressBackgroundView.trailingAnchor constant:-10.0]
]];
// Define vertical constraints, in order from top to bottom
@@ -888,7 +909,8 @@ BOOL isExiting = NO;
BOOL toolbarIsAtTop = [_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop];
BOOL toolbarVisible = _browserOptions.toolbar;
BOOL addressLabelVisible = _browserOptions.location;
-
+ const CGFloat addressBackgroundTopBottomMargin = 12.0;
+
// Center spinner in WebView
[self.spinner.centerXAnchor constraintEqualToAnchor:self.webView.centerXAnchor].active = YES;
[self.spinner.centerYAnchor constraintEqualToAnchor:self.webView.centerYAnchor].active = YES;
@@ -929,10 +951,12 @@ BOOL isExiting = NO;
if (!toolbarVisible && addressLabelVisible) {
// Webview top to safe area top
[self.webView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
- // Address label top to WebView bottom
- [self.addressLabel.topAnchor constraintEqualToAnchor:self.webView.bottomAnchor].active = YES;
- // Address label bottom to safe area bottom
- [self.addressLabel.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor].active = YES;
+ // Address background top to WebView bottom with margin
+ [self.addressBackgroundView.topAnchor constraintEqualToAnchor:self.webView.bottomAnchor
+ constant:addressBackgroundTopBottomMargin].active = YES;
+ // Address background bottom to safe area bottom with margin, margin must be negativ here
+ [self.addressBackgroundView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor
+ constant:addressBackgroundTopBottomMargin *-1].active = YES;
}
// Case 4: Toolbar visible and Address label visible
@@ -943,19 +967,23 @@ BOOL isExiting = NO;
[self.toolbar.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
// Webview top to Toolbar bottom
[self.webView.topAnchor constraintEqualToAnchor:self.toolbar.bottomAnchor].active = YES;
- // Address label top to WebView bottom
- [self.addressLabel.topAnchor constraintEqualToAnchor:self.webView.bottomAnchor].active = YES;
- // Address label bottom to safe area bottom
- [self.addressLabel.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor].active = YES;
+ // Address background top to WebView bottom with margin
+ [self.addressBackgroundView.topAnchor constraintEqualToAnchor:self.webView.bottomAnchor
+ constant:addressBackgroundTopBottomMargin].active = YES;
+ // Address background bottom to safe area bottom with margin, margin must be negativ here
+ [self.addressBackgroundView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor
+ constant:addressBackgroundTopBottomMargin *-1].active = YES;
// Toolbar is at bottom (default)
} else {
// WebView top to safe area top
[self.webView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
- // WebView bottom to Address label top
- [self.webView.bottomAnchor constraintEqualToAnchor:self.addressLabel.topAnchor].active = YES;
- // Address label bottom to Toolbar top
- [self.addressLabel.bottomAnchor constraintEqualToAnchor:self.toolbar.topAnchor].active = YES;
+ // Address background top to WebView bottom with margin
+ [self.addressBackgroundView.topAnchor constraintEqualToAnchor:self.webView.bottomAnchor
+ constant:addressBackgroundTopBottomMargin].active = YES;
+ // Address background bottom to Toolbar top with margin, margin must be negativ here
+ [self.addressBackgroundView.bottomAnchor constraintEqualToAnchor:self.toolbar.topAnchor
+ constant:addressBackgroundTopBottomMargin *-1].active = YES;
// Toolbar bottom to safe area bottom
[self.toolbar.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor].active = YES;
}
@@ -986,7 +1014,7 @@ BOOL isExiting = NO;
- (void)showLocationBar:(BOOL)show
{
- self.addressLabel.hidden = !show;
+ self.addressBackgroundView.hidden = !show;
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org