Skip to content

SwiftUI Package for Configurable Confetti Animation.

License

Notifications You must be signed in to change notification settings

DevLiuSir/ConfettiSwiftUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConfettiSwiftUI It's a customizable confetti animations.

Requirements

  • iOS 14.0+ | macOS 11+
  • Swift 5+

Parameters

parameter type description default
counter Binding on any change of this variable triggers the animation 0
num Int amount of confettis 20
confettis [ConfettiType] list of shapes and text [.shape(.circle), .shape(.triangle), .shape(.square), .shape(.slimRectangle), .shape(.roundedCross)]
colors [Color] list of colors applied to the default shapes [.blue, .red, .green, .yellow, .pink, .purple, .orange]
confettiSize CGFloat size that confettis and emojis are scaled to 10.0
rainHeight CGFloat vertical distance that confettis pass 600.0
fadesOut Bool size that confettis and emojis are scaled to true
opacity Double maximum opacity during the animation 1.0
openingAngle Angle boundary that defines the opening angle in degrees Angle.degrees(60)
closingAngle Angle boundary that defines the closing angle in degrees Angle.degrees(120)
radius CGFloat explosion radius 300.0
repetitions Int number of repetitions for the explosion 0
repetitionInterval Double duration between the repetitions 1.0

Usage

First, add import ConfettiSwiftUI on every swift file you would like to use ConfettiSwiftUI. Define a integer as a state varable which is responsible for triggering the animation. Any change to that variable will span a new animation (increment and decrement).

import ConfettiSwiftUI
import SwiftUI

struct ContentView: View {
    
    @State private var counter: Int = 0
    
    var body: some View {
        Button("click") {
            counter += 1
        }
        .confettiCannon(counter: $counter)
    }
}

Install

Swift Package Manager

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

To integrate ConfettiSwiftUI into your Xcode project using Xcode 12, specify it in File > Swift Packages > Add Package Dependency...:

https://github.com/DevLiuSir/ConfettiSwiftUI.git, :branch="master"

Official Tutorial “Swift Package Manager” tab in Xcode.

Author

DevLiuSir

Software Engineer

License

ConfettiSwiftUI is available under the MIT license. See the LICENSE file for more info.

About

SwiftUI Package for Configurable Confetti Animation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages