### Swift Class with Marks Source: https://github.com/ivanvorobei/spconfetti/blob/main/CONTRIBUTING.md Example of using Swift marks for code structure within a class. Marks help organize code sections like initialization, lifecycle, layout, and access levels. ```swift class Example { // MARK: - Init init() {} } ``` -------------------------------- ### Start and Stop Confetti Animation (UIKit) Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Initiate and terminate confetti animations using static methods. Supports specifying animation type and particle types. An optional duration can be provided for automatic stopping. ```swift // For start animation SPConfetti.startAnimating(.centerWidthToDown, particles: [.triangle, .arc]) // For stop animation SPConfetti.stopAnimating() ``` ```swift SPConfetti.startAnimating(.centerWidthToDown, particles: [.triangle, .arc], duration: 3) ``` -------------------------------- ### Implement Confetti Delegate Protocol Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Receive notifications about animation events by assigning a delegate to your `SPConfettiView` and implementing the `SPConfettiDelegate` protocol methods. ```swift confettiView.delegate = self protocol SPConfettiDelegate: AnyObject { // Caling when animation start. func confettiDidStartAnimating() // Caling when animation stop. func confettiDidStopAnimating() // Caling when animation end. // May calling after `confettiDidStopAnimating`, // becouse after stop emitting particles existing particles // still available. func confettiDidEndAnimating() } ``` -------------------------------- ### CocoaPods Dependency Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Integrate SPConfetti into your project using CocoaPods by specifying it in your Podfile. ```ruby pod 'SPConfetti' ``` -------------------------------- ### Swift Package Manager Dependency Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Add SPConfetti as a dependency to your Swift package using Swift Package Manager. ```swift dependencies: [ .package(url: "https://github.com/ivanvorobei/SPConfetti", .upToNextMajor(from: "1.4.0")) ] ``` -------------------------------- ### Configure Confetti Animation Type Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Customize the emitter's size and direction by setting the `animation` property on a `SPConfettiView` instance. Available animations include full width or center, moving down or up. ```swift enum SPConfettiAnimation { case fullWidthToDown case fullWidthToUp case centerWidthToDown case centerWidthToUp } // To change animation: confettiView.animation = .centerWidthToDown ``` -------------------------------- ### Set Global Confetti Appearance Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Configure default values for all subsequent confetti views using the `SPConfettiConfiguration` static properties. This allows setting default particle types and colors. ```swift SPConfettiConfiguration.particles = [.star] SPConfettiConfiguration.particlesConfig.colors = [.systemRed, .sytemBlue] ``` -------------------------------- ### Basic SwiftUI Confetti Button Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Use this modifier to present confetti effects within the corresponding window scene. It can be attached to any view hierarchy for a full-screen effect. ```swift struct FancyButton: View { @State private var isPresenting = false var body: some View { Button("🎉 hooray!", action: { isPresenting.toggle() }) .confetti(isPresented: $isPresenting, animation: .fullWidthToDown, particles: [.triangle, .arc], duration: 3.0) } } ``` -------------------------------- ### Customize Confetti Particles Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Modify the appearance of confetti particles by setting the `particles` property on a `SPConfettiView`. You can choose from predefined shapes or use a custom image. ```swift // Available `.arc`, `.star`, `.heart`, `.circle`, `.triangle` and `.polygon`. // You can set many styles particles. confettiView.particles = [.star] ``` ```swift confettiView.particles = [.custom(yourImage)] ``` -------------------------------- ### Customized Confetti Particle Velocity in SwiftUI Source: https://github.com/ivanvorobei/spconfetti/blob/main/README.md Customize individual confetti particle properties, such as velocity, using the `.confettiParticle(_:_:)` modifier. This allows for distinct effects on different buttons within the same view. ```swift VStack { Button("Fast", action: { isPresenting1.toggle() }) .confetti(isPresented: $isPresenting1, animation: .fullWidthToDown, particles: [.triangle, .arc], duration: 3.0) .confettiParticle(\.velocity, 600) Button("Slow", action: { isPresenting2.toggle() }) .confetti(isPresented: $isPresenting2, animation: .fullWidthToDown, particles: [.triangle, .arc], duration: 3.0) .confettiParticle(\.velocity, 100) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.