'How to change the background color of Status bar color is displaying at bottom Xamarin iOS
I am using Rg.Plugins.Popup to display Popup in Xamarin iOS. However I want the Status bar color is displaying at bottom of screen it's white to match the Popup's background color. I tried adding the ios:Page.UseSafeArea="true" attribute. However it doesn't work.
This is what I have:
Popup.xaml
<popup:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:popup="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns:ymmy="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true"
BackgroundColor="#ffffff"
.......>
<popup:PopupPage.Animation>
<animations:ScaleAnimation PositionIn="Bottom" PositionOut="Bottom" ScaleIn="1.2" ScaleOut="0.8" DurationIn="400" DurationOut="300" EasingIn="SinOut" EasingOut="SinIn" HasBackgroundAnimation="False"/>
</popup:PopupPage.Animation>
<ymmy:PancakeView x:Name="BgStack" Padding="15" Margin="0" HorizontalOptions="FillAndExpand" VerticalOptions="EndAndExpand" BackgroundColor="#fff" BackgroundGradientStartPoint="0,0" BackgroundGradientEndPoint="0,1" CornerRadius="20,20,0,0">
<StackLayout Padding="12,0" Margin="0">
Grid Margin="0" Padding="0,5" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="CenterAndExpand">
<StackLayout Orientation="Vertical">
<Label HorizontalTextAlignment="Start" Text="Text....." Margin="0" TextColor="#393f57" FontFamily="RobotoMedium" FontSize="16"/>
</StackLayout>
</Grid>
<Grid Grid.Row="0" Grid.Column="1" HorizontalOptions="End" VerticalOptions="CenterAndExpand">
<Image>
<Image.Source>
<FontImageSource Color="#393f57" Size="20" FontFamily="Icon8Font" Glyph="{x:Static local:Icon8FontIcon.AngleRight}"/>
</Image.Source>
</Image>
</Grid>
</Grid>
</StackLayout>
</ymmy:PancakeView>
</popup:PopupPage>
Note that I only want the Status bar color is displaying at bottom of the Popup to be White.
Looking forward to everyone's help. Thank you
Update
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
UITabBar.Appearance.BackgroundImage = new UIImage();
UITabBar.Appearance.ShadowImage = new UIImage();
UITabBar.Appearance.SelectedImageTintColor = UIColor.FromRGB(51, 114, 221);
Rg.Plugins.Popup.Popup.Init();
FFImageLoading.Forms.Platform.CachedImageRenderer.Init();
NativeMedia.Platform.Init(GetTopViewController);
HtmlLabelRenderer.Initialize();
global::Xamarin.Forms.Forms.Init();
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes
{
TextColor = UIColor.Black,
Font = UIFont.FromName("Roboto Medium", 14)
});
Firebase.Core.App.Configure();
LoadApplication(new App());
DependencyService.Register<IAccountService, AccountServiceAuthPhone>();
int red = 11;
int green = 22;
int blue = 33;
bool canLoadUrl = base.FinishedLaunching(app, options);
// get status bar and set color
UIView statusBar;
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
const int tag = 999;
var window = UIApplication.SharedApplication.Delegate.GetWindow();
if (window is null) return null; //Error null
statusBar = window.ViewWithTag(tag) ?? new UIView(UIApplication.SharedApplication.StatusBarFrame)
{
Tag = tag
};
window.AddSubview(statusBar);
}
else
{
statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
}
if (!(statusBar is null))
{
statusBar.BackgroundColor = UIColor.FromRGB(red, green, blue);
}
return canLoadUrl;
}
Solution 1:[1]
change the status bar color in FinishedLaunching,
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
int red = 11;
int green = 22;
int blue = 33;
// the usual Xamarin.Forms code
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
bool canLoadUrl = base.FinishedLaunching(app, options);
// get status bar and set color
UIView statusBar;
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
const int tag = 999;
var window = UIApplication.SharedApplication.Delegate.GetWindow();
if (window is null) return null;
statusBar = window.ViewWithTag(tag) ?? new UIView(UIApplication.SharedApplication.StatusBarFrame)
{
Tag = tag
};
window.AddSubview(statusBar);
}
else
{
statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
}
if (!(statusBar is null))
{
statusBar.BackgroundColor = UIColor.FromRGB(red, green, blue);
}
return canLoadUrl;
}**
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Adrain Zhu -MSFT |


