0
votes

I'm creating mobile app in Xamarin.Forms. I have a problem with ios implementation, I need change default blue color in all button texts, switch etc. to my own color.

In Android I managed this by changing styles.xml and colors.xml but on iOS I have no idea how to change this.

Anyone know what and where I have to change?

1
Does my solution work for you? If yes, can you please accept it (click the ☑️ in the upper left corner of this answer ) so that we can help more people with same problem:).nevermore

1 Answers

1
votes

From the document:

iOS lets you apply visual property settings at a static class level rather than on individual objects so that the change applies to all instances of that control in the application.

This functionality is exposed in Xamarin.iOS via a static Appearance property on all UIKit controls that support it.

So you can set the default appearance values in the first screen:

// Set the default appearance values
UIButton.Appearance.TintColor = UIColor.LightGray;
UIButton.Appearance.SetTitleColor(UIColor.FromRGB(0,127,14), UIControlState.Normal);

UISlider.Appearance.ThumbTintColor = UIColor.Red;
UISlider.Appearance.MinimumTrackTintColor = UIColor.Orange;
UISlider.Appearance.MaximumTrackTintColor = UIColor.Yellow;

UIProgressView.Appearance.ProgressTintColor = UIColor.Yellow;
UIProgressView.Appearance.TrackTintColor = UIColor.Orange;

You can also customize the color by :

UIButton button = new UIButton();
button.SetTitleColor(UIColor.Red, UIControlState.Normal);