Skip to content

Commit c7f8825

Browse files
authored
In banner view, pin top elements to the bottom of the status bar (#5100)
* Add constraint to pin title label below status bar in banner FIAM * Remove title label top pin from storyboard at build time * Use conditional compilation for iOS 13 check
1 parent 9a7754c commit c7f8825

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

FirebaseInAppMessaging/Resources/FIRInAppMessageDisplayStoryboard.storyboard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
</constraint>
9696
<constraint firstItem="GOK-vx-mU8" firstAttribute="leading" secondItem="rzo-9i-rXZ" secondAttribute="leading" id="J6L-hu-jV6"/>
9797
<constraint firstItem="VfB-vw-7up" firstAttribute="leading" secondItem="vRb-yf-OWE" secondAttribute="leading" constant="5" id="gGt-ku-pPu"/>
98-
<constraint firstItem="rzo-9i-rXZ" firstAttribute="top" secondItem="lHf-Ux-dEc" secondAttribute="bottom" constant="3" id="hhi-1K-2YO"/>
98+
<constraint firstItem="rzo-9i-rXZ" firstAttribute="top" secondItem="lHf-Ux-dEc" secondAttribute="bottom" constant="3" placeholder="YES" id="hhi-1K-2YO"/>
9999
<constraint firstItem="VfB-vw-7up" firstAttribute="top" secondItem="rzo-9i-rXZ" secondAttribute="top" id="nF9-EZ-bjS"/>
100100
<constraint firstAttribute="trailingMargin" secondItem="rzo-9i-rXZ" secondAttribute="trailing" id="pOl-wC-mqq"/>
101101
<constraint firstItem="rzo-9i-rXZ" firstAttribute="leading" secondItem="VfB-vw-7up" secondAttribute="trailing" constant="5" id="vSo-6t-cZ0"/>

FirebaseInAppMessaging/Sources/DefaultUI/Banner/FIRIAMBannerViewController.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,25 @@ - (void)viewDidLoad {
155155
self.view.layer.shadowRadius = 2;
156156
self.view.layer.shadowOpacity = 0.4;
157157

158+
// Calculate status bar height.
159+
CGFloat statusBarHeight = 0;
160+
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
161+
if (@available(iOS 13.0, *)) {
162+
UIStatusBarManager *manager =
163+
[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager;
164+
165+
statusBarHeight = manager.statusBarFrame.size.height;
166+
} else {
167+
#endif
168+
statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
169+
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
170+
}
171+
#endif
172+
173+
// Pin title label below status bar with cushion.
174+
[[self.titleLabel.topAnchor constraintEqualToAnchor:self.view.topAnchor
175+
constant:statusBarHeight + 3] setActive:YES];
176+
158177
// When created, we are hiding it for later animation
159178
self.hidingForAnimation = YES;
160179
[self setupAutoDismissTimer];

0 commit comments

Comments
 (0)