Yurkevich
Yurkevich

Reputation: 4517

WKInterfacePicker Caption

Do you know how to add static caption to the watchOS picker? The caption looks like this and it says Item 1.

Black square with Apple Watch picker deploying colours: Red, Green, highlighted in green with bright green caption on top which says item 1

I already selected appropriate style in the Interface Builder:

Displays macOS drop down menu with 3 options. Outline with caption is selected.

My code:

override func awakeWithContext(context: AnyObject?) {
    super.awakeWithContext(context)

    let item1 = WKPickerItem()
    item1.title = "10"
    let item2 = WKPickerItem()
    item2.title = "20"
    let item3 = WKPickerItem()
    item3.title = "30"
    picker.setItems([item1, item2, item3])

    picker.focus()
}

Result I got in the Simulator:

Apple Watch screenshot with the picker and 2 buttons. Picker also outlined in green but doesn't have any caption on top.

How to add missing caption on top of the picker?

Upvotes: 3

Views: 724

Answers (1)

Alessandro Orrù
Alessandro Orrù

Reputation: 3513

You should provide a caption to each WKPickerItem:

let item1 = WKPickerItem()
item1.title = "10"
item1.caption = "CAPTION!"

Upvotes: 4

Related Questions