SwiftConfettiView

master

Swift Confetti View ! Who doesn't like confetti? 🎉🎉
theoriginalbit/SwiftConfettiView

Swift Confetti View Tweet

Related

This project is an updated version of ugurethemaydin/SwiftConfettiView which was a clone of sudeepag/SAConfettiView.

Swift Confetti View! Who doesn't like confetti?

language CI Status License Platform

confetti

It's raining confetti! SwiftConfettiView is the easiest way to add fun, multi-colored confetti to your application and make users feel rewarded. Written in Swift, SwiftConfettiView is a subclass of UIView and is highly customizable. From various types and colors of confetti to different levels of intensity, you can make the confetti as fancy as you want.

To run the example project, clone the repo, and open the Example directory in Xcode 12 or higher.

Installation

Swift Package Manager

Note: Instructions below are for using SwiftPM without the Xcode UI. It's the easiest to go to your Project Settings -> Swift Packages and add Swift Confetti View from there.

To integrate using Apple's Swift package manager, without Xcode integration, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/theoriginalbit/SwiftConfettiView.git", .upToNextMajor(from: "0.2.0"))

and then specify "Swift Confetti View" as a dependency of the Target in which you wish to use Swift Confetti View.

Manual Installation

To manually install SwiftConfettiView, simply add SwiftConfettiView.swift to your project. Make sure you copy the assets over into your bundle too!

Usage

Creating a SwiftConfettiView is the same as creating a UIView:

let confettiView = SwiftConfettiView(frame: self.view.bounds)

Don't forget to add the subview!

self.view.addSubview(confettiView)

Types

Pick one of the preconfigured types of confetti with the .type property, or create your own by providing a custom image. This property defaults to the .Confetti type.

.confetti

confetti

confettiView.type = .confetti
.triangle

triangle

confettiView.type = .triangle
.star

star

confettiView.type = .star
.diamond

diamond

confettiView.type = .diamond
.image

image

confettiView.type = .image(UIImage(named: "smiley")!)

Colors

Set the colors of the confetti with the .colors property. This property has a default value of multiple colors.

confettiView.colors = [.red, .green, .blue]

Intensity

The intensity refers to how many particles are generated and how quickly they fall. Set the intensity of the confetti with the .intensity property by passing in a value between 0 and 1. The default intensity is 0.5.

confettiView.intensity = 0.75

Starting

To start the confetti, use

confettiView.startConfetti()

Stopping

To stop the confetti, use

confettiView.stopConfetti()

Status

To check if the confetti is active and currently being displayed, use

confettiView.isActive

Returns true if it is being displayed, and false if it is not.

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Mar 26 2024 03:29:47 GMT-0900 (Hawaii-Aleutian Daylight Time)