I am building my first xamarian IOS app. The requirements are it has to have a black background, white labels. Text boxes have to be dark with a blue border.
I can set each form item individually, but these seems like the wrong approach. In my ViewDidLoad I am using the following code to change some of the display properties, but some like border color, text color seem to be missing or have to bet set differently. How would I set all the UITextFields borders, text color, and the same for a UITextView?
DepartureMessageView.Layer.BackgroundColor = UIColor.Black.CGColor; UIButton.Appearance.TintColor = UIColor.White; UIButton.Appearance.SetTitleColor(UIColor.White, UIControlState.Normal); UIButton.Appearance.BackgroundColor = UIColor.Blue; UILabel.Appearance.BackgroundColor = UIColor.Black; UILabel.Appearance.TextColor = UIColor.White; UITextField.Appearance.BackgroundColor = UIColor.Black;
text color
There are some missing UIAppearance
features in Xamarin.iOS , such as TextColor
in UITextField.UITextFieldAppearance
.
You have to write your own implementation , use objc_msgSend
to achieve the missing method.
Refer https://stackoverflow.com/a/48270208/8187800
border color
UIAppearance doesn't support on layers , it's impossible to change border with it .
Refer https://stackoverflow.com/a/27404417/8187800
I suggest you subclass UITextField and customize these properties ,then use the new class in your project .
Answers
Unless there is an easier way to apply a dark theme to the full app?
There are some missing
UIAppearance
features in Xamarin.iOS , such asTextColor
inUITextField.UITextFieldAppearance
.You have to write your own implementation , use
objc_msgSend
to achieve the missing method.Refer https://stackoverflow.com/a/48270208/8187800
UIAppearance doesn't support on layers , it's impossible to change border with it .
Refer https://stackoverflow.com/a/27404417/8187800
I suggest you subclass UITextField and customize these properties ,then use the new class in your project .