Skip to content

Commit 340487d

Browse files
fix(ios): center RNNReactButtonView inside navigation bar platter
On iOS 26 the internal _UITAMICAdaptorView wrapper is wider than the React button content and UIKit pins the custom view to the leading edge. This makes the button icon/text appear off-center within the circular Liquid Glass platter. Apply a one-time horizontal CGAffineTransform in layoutSubviews to shift the view to the center of its wrapper. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d969c88 commit 340487d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

ios/RNNReactButtonView.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@implementation RNNReactButtonView {
55
NSLayoutConstraint *_widthConstraint;
66
NSLayoutConstraint *_heightConstraint;
7+
BOOL _didCenter;
78
}
89

910
- (instancetype)initWithHost:(RCTHost *)host
@@ -22,6 +23,7 @@ - (instancetype)initWithHost:(RCTHost *)host
2223
_heightConstraint.priority = UILayoutPriorityDefaultHigh;
2324
_widthConstraint.active = YES;
2425
_heightConstraint.active = YES;
26+
_didCenter = NO;
2527
return self;
2628
}
2729

@@ -41,6 +43,19 @@ - (void)updateConstraintsToFitSize {
4143
}
4244
}
4345

46+
- (void)layoutSubviews {
47+
[super layoutSubviews];
48+
if (!_didCenter && self.superview && self.frame.size.width > 0) {
49+
CGFloat wrapperWidth = self.superview.bounds.size.width;
50+
CGFloat selfWidth = self.frame.size.width;
51+
if (wrapperWidth > selfWidth) {
52+
_didCenter = YES;
53+
CGFloat tx = (wrapperWidth - selfWidth) / 2.0;
54+
self.layer.affineTransform = CGAffineTransformMakeTranslation(tx, 0);
55+
}
56+
}
57+
}
58+
4459
- (NSString *)componentType {
4560
return ComponentTypeButton;
4661
}

0 commit comments

Comments
 (0)