swiftbackground-colorwatchkitwkinterfacelabel

Watchkit: Is it possible to add an image behind a WKInterfaceLabel?


I am trying to add an orange circle with a number (my number will change depending on certain circumstances) inside it in my WKInterfaceGroup like the image below.

enter image description here

However, it appears you can't change WKInterfaceLabel background color. The only solution I can think of is to add an image behind the label. So how can I achieve this (if it is possible)? Is there another way to make this work?


Solution

  • The easiest way to do this is to:

    1. Put the Label into a Group.
    2. Center Align and Position the layout of the Label
    3. Set the Group to a Fixed Width and Height.
    4. Set the Corner Radius of the Group equal to 1/2 the Width (height should be the same)
    5. Set the Group to Background Color to the color you want.