Hi!
I use navigation bar and right buttons on it. Before IOS 13, I had settings for those buttons in AppDelegate:
var attr = UIBarButtonItem.Appearance.GetTitleTextAttributes(UIControlState.Application); attr.Font = UIFont.SystemFontOfSize(15); attr.TextColor = Color.FromHex("#2196F3").ToUIColor(); UIBarButtonItem.Appearance.SetTitleTextAttributes(attr, UIControlState.Normal); UIBarButtonItem.Appearance.SetTitleTextAttributes(attr, UIControlState.Highlighted);
But on new IOS it didn't work. Only way that I find it's write custom render for NavigationPage - but it works only on first page, when I use new NavigationPage(). I need change this style on every place. Please tell me if exist similar way as AppDelegate.``
Try the following code , it works fine on my side .
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0)) { var style = new UINavigationBarAppearance(); var a = new UIStringAttributes(); a.Font = UIFont.SystemFontOfSize(35); a.ForegroundColor = UIColor.Yellow; style.TitleTextAttributes = a; var dic = new NSDictionary<NSString, NSObject>( new NSString[] {a.Dictionary.Keys[0] as NSString, a.Dictionary.Keys[1] as NSString }, a.Dictionary.Values ); var button = new UIBarButtonItemAppearance(UIBarButtonItemStyle.Plain); button.Normal.TitleTextAttributes = dic; button.Highlighted.TitleTextAttributes = dic; style.ButtonAppearance = button; UINavigationBar.Appearance.StandardAppearance = style; } else { var attr = UIBarButtonItem.Appearance.GetTitleTextAttributes(UIControlState.Application); attr.Font = UIFont.SystemFontOfSize(15); attr.TextColor = UIColor.Red; UIBarButtonItem.Appearance.SetTitleTextAttributes(attr, UIControlState.Normal); UIBarButtonItem.Appearance.SetTitleTextAttributes(attr, UIControlState.Highlighted); }
Answers
UIBarButtonItem.Appearance
does not work after iOS13 any more , you could useUINavigationBarAppearance
instead .Try the following code
Refer
https://stackoverflow.com/a/58082187/8187800
https://stackoverflow.com/a/57990366/8187800
I've got errors

Did you test on iOS 13 ? The error shows the class can't be accessible.
I updated XCode and VS. Now I get Exception:
Try the following code , it works fine on my side .
Thanks a lot! It works fine
Has anyone else managed to get this to work? I'm running the latest VS and Xamarin.iOS with an emulated iOS 13.7 and 14.4 and this solution does nothing. Should the code go somewhere other than AppDelegate.cs?
I've literally reduced this to the most simple version I can think of (to set the nav bar title to yellow throughout the app) to test the code works and it's just doing nothing
@ColeX @Yelinzh there is a problem with the Microsoft Q&A site, @Benjff and I are trying to get an answer to this question by posting there but it is throwing access denied errors.