VladimirSN
VladimirSN

Reputation: 3

How do I change the background color of a Table using code? WatchKit

enter image description here

I don't know how to use the - (void)setBackgroundColor:(UIColor *)color

Upvotes: 0

Views: 75

Answers (1)

mattroberts
mattroberts

Reputation: 630

You define a class to act as a row controller. You can have an IBOutlet to your label, but you need an IBOutlet to a Group to have the setBackgroundColor method. You then loop through your rows in your main interface controller, cast them as your row controller class, and then can access the Group and assign it a color with setBackgroundColor. You can assign from a model or an array of UIColor objects. I haven’t done it myself but, based on reading code, it should work.

See https://www.raywenderlich.com/288-watchos-4-tutorial-part-2-tables for some code.

Upvotes: 1

Related Questions