How to remove all gesture recognizers from a UIView in Swift

后端 未结 3 495
余生分开走
余生分开走 2020-12-08 01:55

I have written Swift code that attempts to remove all gesture recognizers from all subviews of a given custom UIView type.

let mySubviews = self.subviews.fil         


        
3条回答
  •  自闭症患者
    2020-12-08 02:40

    Simpler way to do that is

    for subview in self.subviews as [UIView] {
        if subview.isKindOfClass(CustomSubview) {
            subview.gestureRecognizers?.removeAll(keepCapacity: false)
        }
    }
    

提交回复
热议问题