xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.44k stars 509 forks source link

UIPickerView text color doesn't change initially but it gets update on a swipe inside picker #8202

Closed KarthikRajaAKR closed 4 years ago

KarthikRajaAKR commented 4 years ago

I am using UIKit.UIPickerView in Xamarin.iOS project. Here, I can customize the color of Background using BackgrounColor property. But can't change the text color. I used below method, pickerView.SetValueForKeyPath(UIColor.White, (NSString)"textColor");

This doesn't change the color on initial loading but color gets updated if you swipe the picker itself.

Steps to Reproduce

  1. Run the attached sample
  2. Note there is no change in text color of picker
  3. Now scroll picker up and down, you can see the changes in text color.

Images

Initial Loading image

After a swipe image

Expected Behavior

Text Color could be changed on initial loading of Picker.

Actual Behavior

Text color doesn't reflect on picker.

Environment

  1. Visual Studio 2017 and 2019, iPhone 8
  2. var pickerView = new UIPickerView();
    pickerView.Model = new PickerSource();
    
    pickerView.BackgroundColor = UIColor.Blue;
    pickerView.SetValueForKeyPath(UIColor.White, (NSString)"textColor");

Example Project (If Possible)

PickerRenderer.zip

Please help me to come out from this, I would really appreciate if there is any other way to change the TextColor of UIPickerView.

chamons commented 4 years ago

I'm not seeing this on Xcode 11.3 and Xamarin.iOS 13.10.0.21.

The color is white on startup:

image

What Xcode version are you building against? What Xamarin.iOS version? Please post the version info as the issue template requests.

KarthikRajaAKR commented 4 years ago

Hi @chamons, I'm using Xamarin.iOS 12.0, XCode version 10.0 and iPhone 8.

chamons commented 4 years ago

That build is too old for me to even install on my machine. Try updating to more recent Xcode / XI builds and see if that changes the behavior.

I strongly suspect this is an Apple/UIKit behvaior change.

chamons commented 4 years ago

We have not received the requested information.

If you are still experiencing this issue please provide all the requested information then click the Reopen Issue button.

Thanks!