Skip to content

Show the confetti only when the user is having fun, and if not having fun, don't show it.

License

Notifications You must be signed in to change notification settings

ivanvorobei/SPConfetti

Repository files navigation

SPConfetti

A simple solution to show the confetti to the user. Smoothly starts and stops. Allow set multiply diffrent particles at once. You can change shapes and switch between styles. It is possible to change the size and position of emitter. Ready use arc, star, heart triangle shapes. You can set custom shapes with your image.

Navigate

Installation

Ready for use on iOS 11+ and tvOS 11+.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ivanvorobei/SPConfetti", .upToNextMajor(from: "1.4.0"))
]

CocoaPods:

CocoaPods is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile:

pod 'SPConfetti'

Manually

If you prefer not to use any of dependency managers, you can integrate manually. Put Sources/SPConfetti folder in your Xcode project. Make sure to enable Copy items if needed and Create groups.

UIKit

Quick Start

For easy start confetti animation call this:

// For start animation
SPConfetti.startAnimating(.centerWidthToDown, particles: [.triangle, .arc])

// For stop animation
SPConfetti.stopAnimating()

If you want stop animation automatically in time, use it:

SPConfetti.startAnimating(.centerWidthToDown, particles: [.triangle, .arc], duration: 3)

You can manage by view SPConfettiView with custom layout if need.

Animation

For change emitter size and direction, use animation property. Available next animations:

enum SPConfettiAnimation {

    case fullWidthToDown
    case fullWidthToUp
    case centerWidthToDown
    case centerWidthToUp
}

// To change animation:
confettiView.animation = .centerWidthToDown

Particles

You can customise particles style and animation config.

// Available `.arc`, `.star`, `.heart`, `.circle`, `.triangle` and `.polygon`.
// You can set many styles particles.
confettiView.particles = [.star]

For set custom image use .custom case:

confettiView.particles = [.custom(yourImage)]

Global Appearance