【发布时间】:2017-07-13 09:13:16
【问题描述】:
我有一个 UIView 和一些内置在功能 menuState 中的标签和按钮。当我在 menuState 函数中单击一个按钮时,它会将我们带出该函数,进入 menuPlayButtonClicked() 函数。在这个函数中,我试图隐藏我在 menuState 函数中构建的标签和 UIView,因为游戏开始了。使用 menuView.isHidden = true 并没有这样做。 menuView.removeFromSuperView() 也没有这样做。我也尝试使用 let menuView = UIView() 全局声明这些视图和标签,但它仍然没有删除它。我错过了什么?我仍然可以在游戏组件下方的背景中看到标签和 UIView。
func menuState() {
//Build the menu box
let menuView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 400))
menuView.backgroundColor = UIColor(patternImage: UIImage(named: "background.png")!)
self.view.addSubview(menuView)
menuView.layer.zPosition = 1;
menuView.layer.cornerRadius = 10
menuView.isHidden = false
...
Also some code for a button here, which takes us to the setupGame function when clicked
}
【问题讨论】:
标签: ios swift uiview swift3 uilabel