Danger Veger
Danger Veger

Reputation: 1147

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?

Upvotes: 1

Views: 981

Answers (2)

rmp
rmp

Reputation: 3513

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.

Upvotes: 6

Mike Swanson
Mike Swanson

Reputation: 3347

You could add the label to a WKInterfaceGroup and set its background image property. Or, you can create pre-rendered template images and use setTintColor: to color them.

Upvotes: 0

Related Questions