Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overlap two controls in iOS watch kit using interfacebuilder

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 ?

like image 924
N0mi Avatar asked Dec 02 '22 17:12

N0mi


2 Answers

This is possible since watchOS4: 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

like image 199
DrMickeyLauer Avatar answered Dec 29 '22 00:12

DrMickeyLauer


WatchOS4+

For Watch OS4+ follow the answer that @DrMickeyLauer gave.

Outdated answer

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.

like image 44
Tiago Almeida Avatar answered Dec 28 '22 22:12

Tiago Almeida