Tag Archives: UINavigationBar Xamarin

Setting the NavigationBar colors in Xamarin.Android and Xamarin.iOS

WOOT! WOOT! This is regarding my previous post on Setting the NavigationBar colors in Xamarin.Forms!

So I thought it might be handy for some of you to know how to set the NavigationBar colors in Xamarin.Android and Xamarin.iOS! And oh, I’m not going to tell you about the reasons why you would ever want to do this and blah blah as I have mentioned that already in my previous post. lol 😛

When it comes to Xamarin Native level there’s a huge advantage with in-depth customization for any controllers and properties. Therefore some of you might want to dive into the custom renderers when you customize the Navigation Bar and so on. Or may be you are doing a development on native Xamarin.Android app or native Xamarin.iOS app, thereby you may be in need of customizing the NavigationBar (iOS) or the ActivityBar (Android) respectively. However the reasons, let’s get down to business.. 😀

NavigationBar Customization in Xamarin.iOS …. 🙂

Yes in iOS we refer to the NavigationBar just as it is, lol and you could easily customize it by referring to the UINavigationBar.Appearance property.
Here’s some sample customization you could do using these properties, but keep in mind you could constomize this very easily and in-detail according to your preferences, just a matter of a playing around 😉 

// Setting (NavigationBar) Toolbar background color natively
UINavigationBar.Appearance.BarTintColor = Color.FromHex("#ff5300").ToUIColor();
UINavigationBar.Appearance.TintColor = UIColor.White;
UINavigationBar.Appearance.SetTitleTextAttributes(
	new UITextAttributes { TextColor = Color.White.ToUIColor() });

 

ActionBar Customization in Xamarin.Android …. 🙂

Oh Yes! in Android we could refer to the ActionBar via the Context instance or may be if you are inside of an Activity, you could directly static reference it, to access its various Set properties for customization. Here also you could go in-detail according to your preferences, just a matter of a playing around 😉

// Setting ActionBar (Toolbar) background color natively
var actionBar = ((Activity)Context).ActionBar;
actionBar.SetBackgroundDrawable(new ColorDrawable(Xamarin.Forms.Color.FromHex("#ff5300").ToAndroid()));

 

WOOT! WOOT! There you go! 😀

Oh well just another tiny blog post in a boring day I guess.. lol

Cheers!

Stay Awesome! 😀