Set WKInterfacePicker color (text or outline)

不想你离开。 提交于 2019-11-30 19:14:29

问题


Does anyone know how to set the Text color or Focus Style Outline color of a WKInterfacePicker?

I don't see it Interface Builder, not am I able to find any property items in code where I can set it.

Here's IB:


回答1:


You cannot change the color of the default picker.

But you can manipulate the views to make it look like it without slowing down the app.

I created this with 2 WKInterfaceGroup aligned vertically. The group on top has a WKInterfaceLabel for custom caption label, and the group below has a WKInterfacePicker. The WKInterfacePicker is configured as such:

Style: List 
Focus Style: None
Indicator: Disabled 

This will hide the default tint & caption so that we can create custom ones.

In the WKInterfaceGroup for label, I set a corner radius and a background color. In the WKInterfaceGroup for picker, I set a background image, which is an image of a stroked rounded rect.

I use pickerDidFocus and pickerDidResignFocus callbacks to change the background color of the WKInterfaceGroup for label, and background image for WKInterfaceGroup for picker.

Use the picker action whenever the index changes, to update the custom action label.

The result is a custom picker that looks exactly like the built-in WKInterfacePicker, but with a custom tint.



来源:https://stackoverflow.com/questions/40923649/set-wkinterfacepicker-color-text-or-outline

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!