void UpdateHideNavigationBarSeparator() { bool shouldHide = NavPage.OnThisPlatform().HideNavigationBarSeparator(); // Just setting the ShadowImage is good for iOS11 if (_defaultNavBarShadowImage == null) _defaultNavBarShadowImage = NavigationBar.ShadowImage; if (shouldHide) NavigationBar.ShadowImage = new UIImage(); else NavigationBar.ShadowImage = _defaultNavBarShadowImage; if (!Forms.IsiOS11OrNewer) { // For iOS 10 and lower, you need to set the background image. // If you set this for iOS11, you'll remove the background color. if (_defaultNavBarBackImage == null) _defaultNavBarBackImage = NavigationBar.GetBackgroundImage(UIBarMetrics.Default); if (shouldHide) NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); else NavigationBar.SetBackgroundImage(_defaultNavBarBackImage, UIBarMetrics.Default); } }
void SetStatusBarStyle() { var barTextColor = NavPage.BarTextColor; var statusBarColorMode = NavPage.OnThisPlatform().GetStatusBarTextColorMode(); if (statusBarColorMode == StatusBarTextColorMode.DoNotAdjust || barTextColor.Luminosity <= 0.5) { // Use dark text color for status bar UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.Default; } else { // Use light text color for status bar UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent; } }
void UpdateBarTextColor() { var barTextColor = NavPage.BarTextColor; var globalAttributes = UINavigationBar.Appearance.GetTitleTextAttributes(); if (barTextColor == Color.Default) { if (NavigationBar.TitleTextAttributes != null) { var attributes = new UIStringAttributes(); attributes.ForegroundColor = globalAttributes.TextColor; attributes.Font = globalAttributes.Font; NavigationBar.TitleTextAttributes = attributes; } } else { var titleAttributes = new UIStringAttributes(); titleAttributes.Font = globalAttributes.Font; // TODO: the ternary if statement here will always return false because of the encapsulating if statement. // What was the intention? titleAttributes.ForegroundColor = barTextColor == Color.Default ? titleAttributes.ForegroundColor ?? UINavigationBar.Appearance.TintColor : barTextColor.ToUIColor(); NavigationBar.TitleTextAttributes = titleAttributes; } if (Forms.IsiOS11OrNewer) { var globalLargeTitleAttributes = UINavigationBar.Appearance.LargeTitleTextAttributes; if (globalLargeTitleAttributes == null) NavigationBar.LargeTitleTextAttributes = NavigationBar.TitleTextAttributes; } var statusBarColorMode = NavPage.OnThisPlatform().GetStatusBarTextColorMode(); // set Tint color (i. e. Back Button arrow and Text) NavigationBar.TintColor = barTextColor == Color.Default || statusBarColorMode == StatusBarTextColorMode.DoNotAdjust ? UINavigationBar.Appearance.TintColor : barTextColor.ToUIColor(); }
void UpdateTranslucent() { NavigationBar.Translucent = NavPage.OnThisPlatform().IsNavigationBarTranslucent(); }
void UpdateUseLargeTitles() { if (Forms.IsiOS11OrNewer && NavPage != null) NavigationBar.PrefersLargeTitles = NavPage.OnThisPlatform().PrefersLargeTitles(); }