Change UIPickerView background

前端 未结 9 1054
天涯浪人
天涯浪人 2020-11-27 15:38

I want to change the border color of a UIPickerView. I do not see a tint property for the UIPickerView. Is there any way this could be done? Or a workaround?

Thanks.

9条回答
  •  一生所求
    2020-11-27 16:40

    You can change background color by completely replacing the background image with one of your choice using IXPickerOverlayView available on GitHub (the repo contains an illustrated example of using this class).

    Note that you'll have to draw out the (rectangular) background yourself from scratch but unlike any of the workarounds mentioned here this approach is fully dynamic: the control will look correctly even if you change the number of picker wheels and their sizes in runtime (like UIDatePicker does when you change your system locale setting).

    Once you have your background image, using IXPickerOverlayView is as simple as adding a IXPickerOverlayView instance on top of your Picker view and assigning hostPickerView property.

提交回复
热议问题