![](/img/trans.png)
[英]how to change default color when switch is “on”(blue to green) in forms xamarin. In ios default it is GReen but in android it is blue
[英]Xamarin.Forms how to change default blue color on ios
我正在 Xamarin.Forms 中创建移动应用程序。 我对 ios 实现有疑问,我需要将所有按钮文本中的默认蓝色、切换等更改为我自己的颜色。
In Android I managed this by changing styles.xml and colors.xml but on iOS I have no idea how to change this.
任何人都知道我必须改变什么以及在哪里改变?
从文件:
iOS 允许您在 static class 级别而不是单个对象上应用视觉属性设置,以便更改适用于应用程序中该控件的所有实例。
此功能在 Xamarin.iOS 中通过 static Appearance
属性在所有支持它的 Z9CFED124ECBE656AF2584273 控件上公开。
因此,您可以在第一个屏幕中设置默认外观值:
// 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;
您还可以通过以下方式自定义颜色:
UIButton button = new UIButton();
button.SetTitleColor(UIColor.Red, UIControlState.Normal);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.