Reza Kashkoul
Reza Kashkoul

Reputation: 53

Swift - WatchKit: Setting background color for selected row on table (WKInterfaceTable)

Swift - WatchKit: How to set background color for selected row on watch tables? thanks in advance

Upvotes: 0

Views: 88

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100541

Make the background as Group

@IBOutlet weak var cellBackGroup: WKInterfaceGroup!

Then set

row.cellBackGroup.setBackgroundColor(UIColor.red)

You can keep a variable

var selectedIndex = 0

and implement delegate method

func table(_ table: WKInterfaceTable,  didSelectRowAt rowIndex: Int) {
    selectedIndex = rowIndex
    ....
}

Upvotes: 1

Related Questions