2

I was making a simple app with a slider and then I thought how can I change the background colour of the Apple Watch programatically. I know how you would normally do it for the iPhone but don't have a clue of what this one could be!

Airspeed Velocity
  • 40,491
  • 8
  • 113
  • 118
george barlow
  • 125
  • 3
  • 12

3 Answers3

4

There is no API to change the color of a WKInterfaceController, you can set the color in InterfaceBuilder, but not in code.

Apple highly recommends to use the black color in Apple Watch Human Interface Guidelines:

Use black for your app’s background color. A black background blends seamlessly with the device bezel and maintains the illusion of no screen edges. Avoid bright background colors in your interface.

zisoft
  • 22,770
  • 10
  • 62
  • 73
1

This question covers a lot of details that this question is asking (I've summarized below). How can I set the backgroundColor of a WKInterfaceController programatically?

  1. You cannot change the background of the watch face as of WatchKit 3. You can change the background color of a group control.
  2. Add a group to your WatchKit app.
  3. Create a corresponding outlet for your group and set the background color programatically like this ('self' may not be required in your context).

    Figure 1. setBackgroundColor

  4. Set the group's radius to '0' to removed the rounded corners that reveal the background color of the watch face

Figure 2. Radius Settings

  1. Set the Interface Controller's insets to '0' to remove the left and right edges that reveal the background color of the watch face

Figure 3. Insets

M. Travis Volker
  • 2,310
  • 3
  • 20
  • 21
  • I don't beleive this works anymore. I receive an error if I attempt hook the Group's outlet to my rowcontroller - "Can't connect the outlet to repeating content". I don't have a solution or have come across anything yet – Mark Mar 05 '20 at 05:28
  • 1
    Can't correct my comment above but it does work for me as of today. I had to clean and remove associated outlet to the rowGroup and readd it again – Mark Mar 05 '20 at 05:56
0

According to the apple developer documentation,you can follow the following syntax

func setBackgroundColor(_ color: UIColor?)

if you do not specify a custom background color or if you set the custom color to nil, the group uses the color assigned to the group object in your storyboard file. The default background color is clear.

Further,The solid background color to be displayed behind all items in the group. Specify nil to remove the custom color you previously set using this method.

Keshav
  • 1,123
  • 1
  • 18
  • 36