ugurethemaydin / SwiftConfettiView

Swift Confetti View ! Who doesn't like confetti? 🎉🎉
MIT License
254 stars 30 forks source link

all my other tap gestures stop after stopping confetti #4

Open theofficejackpot opened 4 years ago

theofficejackpot commented 4 years ago

Hi, most likely just my ignorance. I got confetti to work (yay). But then all my other tap gestures stop working. I'm sure it's something simple?

In my code, I have:

self.startConfetti()
                        var timer = Timer()
                        let s = 4
                        timer = Timer.scheduledTimer(timeInterval: TimeInterval(s), target: self, selector: #selector(self.stopConfetti), userInfo: nil, repeats: false)

Then these are my two functions:

@objc func stopConfetti() {
            confettiView.stopConfetti()
            view.willRemoveSubview(confettiView)
    }
    func startConfetti() {
        confettiView = SwiftConfettiView(frame: self.view.bounds)

        // Set colors (default colors are red, green and blue)
        confettiView.colors = [UIColor(red:0.95, green:0.40, blue:0.27, alpha:1.0),
                               UIColor(red:1.00, green:0.78, blue:0.36, alpha:1.0),
                               UIColor(red:0.48, green:0.78, blue:0.64, alpha:1.0),
                               UIColor(red:0.30, green:0.76, blue:0.85, alpha:1.0),
                               UIColor(red:0.58, green:0.39, blue:0.55, alpha:1.0)]

        // Set intensity (from 0 - 1, default intensity is 0.5)
        confettiView.intensity = 0.75

        // Set type
        confettiView.type = .confetti

        // For custom image
        // confettiView.type = .Image(UIImage(named: "diamond")!)

        // Add subview
        view.addSubview(confettiView)

        self.confettiView.startConfetti()
    }
theofficejackpot commented 4 years ago

fyi, this is what I got to work:

    @objc func stopConfetti() {
            confettiView.stopConfetti()
            view.willRemoveSubview(confettiView)
            confettiView.removeFromSuperview()
    }
rathodmayur93 commented 3 years ago

Send the confetti view to the back of the view view.sendSubviewToBack(confettiView)