简体   繁体   English

在iOS上与用户互动进行抽奖

[英]Lottie with user interaction on iOS

In my iOS app I have lottie animation, which is on the whole screen. 在我的iOS应用中,我有很多动画,这些动画在整个屏幕上显示。 During animation user interactions are not available. 在动画期间,用户交互不可用。 I want to make everything under animation active to user interaction (scroll, buttons, etc.) Is there any chance to do it? 我想使动画下的所有内容都对用户交互有效(滚动,按钮等)。是否有机会这样做?

CODE: 码:

guard let mainView = self?.view, let animationView = LOTAnimationView(name: "someName") else { return }

animationView.frame = CGRect(x: 0,
                             y: 0,
                         width: mainView.frame.size.width,
                        height: mainView.frame.size.height)

animationView.contentMode = .scaleAspectFill
animationView.loopAnimation = false

mainView.addSubview(animationView)

animationView.play() { _ in
    animationView.removeFromSuperview()
}

Did you tried adding gesture recognizers to Lottie view ? 您是否尝试过将手势识别器添加到Lottie视图中?

Edit after code attach : 附加代码后进行编辑:

you can try add gestureRecognizer to animationView and add parameter (sender) on your function. 您可以尝试将gestureRecognizer添加到animationView,然后在函数上添加参数(发送者)。

func handleTap(sender: UITapGestureRecognizer) {
    if sender.state == .ended {
        // handling code
    }
}

I bet disabling user interaction for the animation view would do the trick. 我敢打赌,禁用动画视图的用户交互将达到目的。 Try something like: animationView.userInteractionEnabled = false . 尝试类似的方法: animationView.userInteractionEnabled = false This should prevent touches from being consumed by the animationView and not being propagated down the view hierarchy. 这应防止触摸被animationView占用,并且不会沿视图层次结构传播。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM