我有一个UIView
var transparentBackground = UIView()
单击按钮时,视图会显示一些属性
@IBAction func UserViewImage(_ sender: UIButton) -> Void {
self.transparentBackground = UIView(frame: UIScreen.main.bounds)
self.transparentBackground.backgroundColor = UIColor(white: 0.0, alpha: 0.4)
UIApplication.shared.keyWindow!.addSubview(self.transparentBackground)
self.opaqueView = self.setupOpaqueView()
self.transparentBackground.addSubview(opaqueView)
UIApplication.shared.keyWindow!.bringSubview(toFront: self.transparentBackground)
self.view.bringSubview(toFront: transparentBackground)
}
当单击另一个按钮时,视图完全被解除,并带有一个名为removeAnimate的函数。
func handleOKButtonTapped(_ sender: UIButton){
removeAnimate()
}
但是,我希望在单击背景(视图)时视图完全被解除,就像单击按钮时一样,所以我这样做了:
override func viewDidLoad() {
super.viewDidLoad()
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(removeAnimate))
self.transparentBackground.addGestureRecognizer(gestureRecognizer)
}
但它不起作用,我不确定我做错了什么。不透明的blueBackground视图中有一个子视图。
self.transparentBackground.addSubview(opaqueView)
答案 0 :(得分:0)
这是我实现这个的方式:
val m = l.filter(_._3 != 0).map(a => a._2.split('.')(0) -> a._3)