我试图在触发函数时在 subview 中隐藏 UIButton。 我对该层次结构有多个 View :
var takePhotoButton : UIButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
takePhotoButton.addTarget(self, action:"takePhoto", forControlEvents:UIControlEvents.TouchUpInside)
var savePhotoButton : UIButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
let view2:UIView = UIView(frame: CGRectMake(0, 0, 320, 568))
self.view.addSubview(photoMask)
photoMask.addSubview(view2)
view2.addSubview(takePhotoButton)
我想在触发以下函数时隐藏 takePhotoButton,我该怎么做?
func takePhoto(takePhotoButton: UIButton!) {
takePhotoButton.hidden = true
}
最佳答案
如果要保留对 UIButton 的引用,则必须使 UIButton 成为该类的属性。然后您可以使用 self.takePhotoButton
访问它。
关于ios - swift : Hide button in subview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25890608/