Change UIPickerView background

前端 未结 9 1070
天涯浪人
天涯浪人 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:38

    My UIPickerView has 3 components. And no Selection Indicator.

    This gives it 11 subviews. [[picker subviews] count]

    Hiding the first and the last subview totally removes the background.

    [(UIView*)[[picker subviews] objectAtIndex:0] setHidden:YES];
    [(UIView*)[[picker subviews] objectAtIndex:10] setHidden:YES];
    

    Hiding every third other subview (indexes 1, 4 and 7) hides the opaque background on the components. Giving quite a nice effect that I can skin as I desire.

    Hope that helps someone :)

提交回复
热议问题