UIPickerView, detect “rolling wheel” start and stop?

前端 未结 7 1639
悲哀的现实
悲哀的现实 2020-12-18 04:30

I just discovered that if I do the following:

  1. Click the button that animates a UIPickerView into my view
  2. Quickly start the wheel rolling
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 05:06

    Swift 4 (updated) version with extension of @DrainBoy answers

    extension UIView  {
     func isScrolling () -> Bool {
    
        if let scrollView = self as? UIScrollView {
            if  (scrollView.isDragging || scrollView.isDecelerating) {
                return true
            }
        }
    
        for subview in self.subviews {
            if ( subview.isScrolling() ) {
                return true
            }
        }
        return false
     }
    }
    

提交回复
热议问题