问题
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