[英]Have horizontally aligned WKInterface elements fill view
I am trying to place 2 WKInterfaceButton items side by side on an Apple watch app. 我试图在Apple手表应用程序上并排放置2个WKInterfaceButton项目。 I have a WKInterfaceGroup which I set its layout to horizontal.
我有一个WKInterfaceGroup,我将其布局设置为水平。 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) .
问题是让它们完全并排放置并填充屏幕宽度并自动调节,无论手表大小(38或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. 我需要的是一种将WKInterface元素(在本例中为按钮)设置为手表可用尺寸的一半的方法。 In a normal app you can use
在普通的应用程序中,您可以使用
uiElementWidth = [UIScreen mainScreen].bounds.size.width/2
Is there an equivalent in WatchKit? 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:
选择按钮并使其宽度相对于容器,如下所示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.