storyboardwatchkitwkinterfacegroupwkinterfaceobject

How do I change the height type of a WKInterfaceObject programmatically?


In a WatchKit storyboard, if you add a WKInterfaceObject (e.g. WKInterfaceGroup), you have the following height and width options:

  1. Size To Fit Content
  2. Relative to Container (value and Adjustment)
  3. Fixed (value)

In the WKInterfaceObject header, there is only one property associated with height:

func setHeight(height: CGFloat)

... in the documentation it states:

Sets the absolute height (in points) of the object.

This looks like it corresponds with option #3 (fixed value).

How do I choose any of the other 2 options programmatically (e.g. what if I want to change the size to "Relative to container")?


Solution

  • You can't change the height to anything other than fixed values currently, so instead create multiple objects in the storyboard with each one configured for the height options you want and hide/show them as needed to get the effect you're looking for. Since the containers in WatchKit are all stacking-based, the hidden objects won't take up any space.