我的标签不会停留在学习游戏的按钮上方
My label will not stay over the button in my learning game
有没有办法在代码中强制标签显示在顶层(在 Swift 中)而不被其他元素掩埋?我没有使用自动布局
我做了一个简单的游戏,每猜对一个答案,屏幕就会向下移动。但是,标签应该保留在每行 3 个按钮的 "on top" 中。发生的情况是标签在屏幕向下移动时被按钮覆盖或部分覆盖。
非常感谢
// if tile row is too low, move row to the top
if (WhiteTile1.center.y >= 601) {
WhiteTile1.center.y = -71
GreyTile1.center.y = -71
BlackTile1.center.y = -71
colorText1.center.y = -142
word1 = wordarray[ofThree()]
colorText1.text = word1
colorText1.hidden = false
}
// colorText1 是标签 .. WhiteTile1 等是按钮。
我认为您正在寻找的方法是 bringSubviewToFront(UIView)
。如果您在父视图控制器中,它看起来像:
self.view.bringSubviewToFront(colorText1)
您调用该方法以将 UILabel 保持在父视图的视图层次结构顶部的策略完全取决于您的处理方式。
有没有办法在代码中强制标签显示在顶层(在 Swift 中)而不被其他元素掩埋?我没有使用自动布局
我做了一个简单的游戏,每猜对一个答案,屏幕就会向下移动。但是,标签应该保留在每行 3 个按钮的 "on top" 中。发生的情况是标签在屏幕向下移动时被按钮覆盖或部分覆盖。
非常感谢
// if tile row is too low, move row to the top
if (WhiteTile1.center.y >= 601) {
WhiteTile1.center.y = -71
GreyTile1.center.y = -71
BlackTile1.center.y = -71
colorText1.center.y = -142
word1 = wordarray[ofThree()]
colorText1.text = word1
colorText1.hidden = false
}
// colorText1 是标签 .. WhiteTile1 等是按钮。
我认为您正在寻找的方法是 bringSubviewToFront(UIView)
。如果您在父视图控制器中,它看起来像:
self.view.bringSubviewToFront(colorText1)
您调用该方法以将 UILabel 保持在父视图的视图层次结构顶部的策略完全取决于您的处理方式。