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

85 Views Asked by At

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

1

There are 1 best solutions below

4
Shehata Gamal On

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
    ....
}