答案 0 :(得分:1)
let view1 = UIView()
let view2 = UIView()
let view3 = UIView()
@IBAction func showView1BtnPressed() {
hideOtherViewsExcept(forView: view1)
}
@IBAction func showView2BtnPressed() {
hideOtherViewsExcept(forView: view2)
}
@IBAction func showView3BtnPressed() {
hideOtherViewsExcept(forView: view3)
}
func hideOtherViewsExcept(forView view: UIView) {
view1.isHidden = true
view2.isHidden = true
view3.isHidden = true
view.isHidden = false
}