Riyas
Riyas

Reputation: 495

Customize Picker background color and Title Color in xamarin forms ios

I am looking for "Highlight the Picker with Background color whenever it is clicked" and also "Title Color"

And when i click other picker the previous picker has to be change to default color, and current clicked picker has to be change color.

I tried with PickerName.BackgroundColor property in code behind, but its not working properly, sometimes its not changing. Is there any other way or how to achieve this using custom renderer or anything?. Thanks in advance.

Upvotes: 1

Views: 6220

Answers (2)

Mayur Kerasiya
Mayur Kerasiya

Reputation: 206

try below code

Device.BeginInvokeOnMainThread(() =>
{
  picker.BackgroundColor = Color.Red;
  picker.TextColor=Color.Pink;
});

Upvotes: 1

Venkata Swamy Balaraju
Venkata Swamy Balaraju

Reputation: 1481

We can change BackgroundColor in SelectedIndexChanged event in PCL.

picker.SelectedIndexChanged += (sender, args) =>
 {
     picker.BackgroundColor=Color.Red;
 };

(or)

We can achieve this through CustomRenderer.

Example: https://forums.xamarin.com/discussion/18563/custom-renderer-for-picker

Xamarin.iOS

http://www.c-sharpcorner.com/article/uipickerview-in-xamarin-ios/

Find Override method for Picker Selection in Xamarin.iOS and put that override method in CustomRenderer and in that change the background color

Upvotes: 1

Related Questions