本文介绍了如何使用interfacebuilder重叠iOS手表套件中的两个控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个带有图像的按钮,我想将一个按钮重叠在另一个按钮上.甚至有可能做到 iOS Watch 吗?此外,如何在手表编程中处理 WKInterfaceObject 的背景或前景深度,如 sendViewtoBackground 或 becomeSubViewtoFront,就像在正常的 iOS 编程中一样?

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 ?

推荐答案

WatchOS4+

对于 Watch OS4+ 遵循@DrMickeyLauer 给出的答案.

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

过时的答案

在手表中,您没有 Z 层次结构.

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.

另一种选择(hack?)是将所有层次结构渲染到 UIImage 中并将其设置在手表中.

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

这篇关于如何使用interfacebuilder重叠iOS手表套件中的两个控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 01:19