I am trying to place 2 WKInterfaceButton items side by side on an Apple watch app. I have a WKInterfaceGroup which I set its layout to horizontal. This allows me to position the buttons next to each other. The issue is having them both fit exactly side by side and fill the screens width and auto adjusting regardless of watch size (38 or 42mm) . Currently I align one left the other right. Then to adjust the widths i have to manually adjust the widths until it looks correct. This seems a bit too hard coded as it doesn't allow for any future watch screen size changes.
What I need is a way to set a WKInterface element (in this case a button) to be half the available size of the watch. In a normal app you can use
uiElementWidth = [UIScreen mainScreen].bounds.size.width/2
Is there an equivalent in WatchKit?
You can rely on the storyboard to do this. Select the button and make its width to be relative to the container like the following:
use Group as container and inside it align your buttons as left, center, right and Yah! use relative to container as told by Ashraf Tawfeeq
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With