首页 > 解决方案 > 当 UIViewPropertyAnimator 运行时,具有按钮的子视图的 ScrollView 不可点击

问题描述

我正在使用 scrollView 和 UIViewPropertyAnimator.runningPropertyAnimator 制作幻灯片动画,但我面临子视图按钮不可点击的问题,为了验证它是否来自动画,我停止了动画代码并且按钮开始触发它们的动作

下面是我正在使用的代码

 UIViewPropertyAnimator.runningPropertyAnimator(withDuration: Double(4 * self.data.count), delay: 0, options: .allowUserInteraction, animations: {
            guard self.data.count > 0 else { return }
            self.scrollView.contentOffset.x = self.cells[self.cells.count - 1].frame.maxX
        }) { (animatingPositionView) in
            switch animatingPositionView {
            case .current:
                break
            case .end:
                if self.scrollView.contentOffset.x == self.cells[self.cells.count - 1].frame.maxX {
                    self.scrollView.contentOffset.x = -self.frame.width
                    self.startScrolling()
                }
            case .start:
                break
            @unknown default:
                break
            }
        }

标签: swiftuiviewpropertyanimator

解决方案


推荐阅读