How to overlap two controls in iOS watch kit using interfacebuilder

自作多情 提交于 2020-01-04 04:14:48

问题


I have two button with images and i want to overlap one over another. Is it even possible to do it iOS Watch? Moreover, how to handle background or foreground depth of a WKInterfaceObject in watch programming, like sendViewtoBackground or bringSubViewtoFront, as in normal iOS programming ?


回答1:


In the watch you don't have a Z hierarchy.

The max you can do is using a group, that has a background and then have controls over that background.

Another alternative (hack?) is to render all your hierarchy into an UIImage and set it in the watch.




回答2:


In watchOS4, it's now possible – you can use groups to create overlapping content. Set the group's Layout attribute in the Attribute inspector to "Overlap". The system positions each item in the group based on the item's alignment attributes.

More info @ https://developer.apple.com/documentation/watchkit/wkinterfacegroup




回答3:


No, you cannot, using iOS normal programming.

You can have two hack:

  • Create a Group, and hide the button you don't want to see. Hide/Unhide your button when you want to change.

  • Manage on the same WKButton: You change the image on the button, and depending the image you modify your logic (Not a very good hack).



来源:https://stackoverflow.com/questions/29748622/how-to-overlap-two-controls-in-ios-watch-kit-using-interfacebuilder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!