我在水平 UICollectionView 中有从 UIControl 继承的按钮。我想添加一个行为,这样即使我们水平滚动按钮,我的按钮也不会被触摸到,首先滚动会捕捉到 UICollectionView
-- UICollectionView
-- UIControl (button)
-- UIControl (button)
-- UIControl (button)
如何做到这一点?
UICollectionView 继承自 UIScrollView。所以你可以访问;
open var isTracking: Bool { get } // returns YES if user has touched. may not yet have started dragging
open var isDragging: Bool { get } // returns YES if user has started scrolling. this may require some time and or distance to move to initiate dragging
open var isDecelerating: Bool { get } // returns YES if user isn't dragging (touch up) but scroll view is still moving
我会使用这些检查来查看集合是否在滚动,如果是,则从所有按钮点击返回。