I'm using a Side Menu iOS (not my choice just by the way) and I stumbled upon an issue that can be seen in the following image:
If you look close enough in the above figure, the red rectangle is actually highlighting the text 'Menu' that used to open the side menu and it's barely visible. It's quite simply changing the navigation bar text color which doesn't seem to affect that color.
How do I change the default color that is appearing above?
The tint determines this color.
You can change it globally by settting
UINavigationBar.Appearance.TintColor
If you just want to change the color of the menu button in a specific ViewController . Add the following code in the method ViewWillAppear() of your ViewController
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
this.NavigationController.NavigationBar.TintColor = UIColor.FromRGB(xxx,xxx,xxx);
}
NavigationPage has a property called BarTextColor, on iOS devices, this property changes the colour of both the navigation bar text and the menu button text. The following solution might be a problem though if one would like to have separate colours for each of the latter:
MainPage = new NavigationPage(YourPage) { BarBackgroundColor = Color.FromHex(#SomeHex), BarTextColor = Color.Red};
BarTextColor = Color.Red produces the following output:
Related
I have a forms application that has a dark mode. However the Apple information that appears at the top of the display and also the slider bar at the bottom appear to very bright. Is there a way to change the color of these?
The top bar can only be black or white, or if you don't want to see it at all, you can hide it.
The bottom (tab) bar, can be influenced, you can use the Appearance APIs on iOS. For example, in your AppDelegate.cs file add a line like this: UITabBar.Appearance.TintColor = Color.Red.ToUIColor();
There are more advanced scenarios possible, have a look at my blog post about it here: https://blog.verslu.is/xamarin/xamarin-forms-xamarin/spicing-up-your-xamarin-formsios-tabbar/
And the (open) PR on the Xamarin.Forms repo here, which will makes this possible from the Forms framework directly: https://github.com/xamarin/Xamarin.Forms/pull/4899
In app delegates.cs find Finishlaunching method and all following code. Also set the color accordingly.
UINavigationBar.Appearance.BarTintColor = UIColor.FromRGB(190, 18, 40);
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes { TextColor =
UIColor.Blue});
My application uses a tab page and when I push a new page then a back navigation arrow appears with a word to the right of it.
In iOS it's blue. How can I change the color of this arrow and the text with Xamarin Forms?
The color is tied to the BarTextColor of the NavigationPage.
You can change the text by setting the Title of each page, that is what is shown by default. You can also change this by setting it through the SetBackButtonTitle(Page, string) method.
I'm trying to set the background color of the text field in my search bar to a custom color. I looked at the answer here to no avail:
Cannot change search bar background color
See how that search bar has a red text field? I followed the code and can even verify that the UISearchBarTextField object was found and the background color of it is being set to UIColor.red, but the color does not change.
I've messed around with all the background colors of the superviews with hopes that it might help but I cannot get that color to change. Maybe there's some new trick or someone can shed some light on something that may be overriding the color somehow.
extension UISearchBar {
var textField: UITextField? {
return subviews.first?.subviews.first(where: { $0.isKind(of: UITextField.self) }) as? UITextField
}
}
searchBar.textField?.backgroundColor = UIColor.red // <-- Not working
let textFieldInsideUISearchBarLabel = searchBar.textField?.value(forKey: "placeholderLabel") as? UILabel
textFieldInsideUISearchBarLabel?.textColor = UIColor.lightGray
Note that the text inside the UITextField object is changing to the lightGray like I want it, just not the UITextField background color.
After a long wait for an answer, I decided to try some experiments. I created a new project, dragged a search bar, connected it to the ViewController, added the UISearchBar extension, and set the color - exactly the same as I did in my main project.
Voila! It does set the background color as it should, and as it shows in the linked topic in the main question.
So, I put the projects side by side, opened the storyboard in each of them and started setting the properties of the searchBar, one at a time, until I could see why the bar is not being set like it should in the main project.
The very first thing I tried was, search style. My project has it set to "Minimal". I changed it to "Minimal" in the test project and noticed right away that the color was no longer set.
So, setting the "Search Style" property of the searchBar in the main project to "Default" allowed that background color to be set.
I would appreciate it greatly if anyone could comment and say why it is that I can't use "Minimal" if I want to customize the background color, or how I could make it work.
Using xamarin forms (PCL),
I searched a lot but Can not find the exact solution,
Can i change the back button in toolbar or at least should i be able to change its color and the title color as well?
I am not sure for changing back button, but I was changing back button and title color.
An example, in App.cs file OnStart method I set that LoginPage is first page with black title, on this way
MainPage = new NavigationPage(new LoginPage()) { BarTextColor = Color.Black };
Please try something like this, I have some other examples if this one doesn't work.
I want to have a unified toolbar and therefore I found this post:
How can I create Yosemite-style unified toolbar in Interface Builder?
self.window.titleVisibility = NSWindowTitleVisibility.Hidden
works perfect.
But is there a way to change the background color for the toolbar? I tried with self.window.appearance = NSAppearance(named: NSAppearanceNameVibrantDark), but this only brings a complete black toolbar (that's too dark). I want to have a custom color.
This one works:
https://stackoverflow.com/a/28692893/2062613
Set the window to textured in IB (I don't see a possibility to do it at runtime)
Use this code:
self.window.titleVisibility = NSWindowTitleVisibility.Hidden
self.window.backgroundColor = NSColor.whiteColor()
UPDATE:
To prevent, that the toolbar becomes transparent in Yosemite (if you have a scrollview below the Toolbar), use this code:
self.window.appearance = NSAppearance(named: NSAppearanceNameAqua)
I have used this solution to customize the title bar. However, since 10.15.4 and apparently on Big Sur, the toolbar is broken. If you have a toolbar with the window, the toolbar will placed on the top edge of the window, as if there is no title bar.