Latest 1.0.0
Homepage https://github.com/lachlanbell/LBConfettiView
License MIT
Platforms ios 8.0
Authors

Build Status
Version
License
Platform
Swift Version
PRs Welcome

LBConfettiView

Usage

Use the example app to experiment with these different properties

Basic Usage

// Create confetti view
let confettiView = ConfettiView(frame: self.view.bounds)

// Add confetti view as subview
self.view.addSubview(confettiView)

// Start the confetti 🎉
confettiView.start()

Animation

The confetti animation can be started and stopped by calling the start() and stop() methods.

Starting

confettiView.start()

Stopping

confettiView.stop()

To immediately clear all confetti on stopping, the clear argument can be given as true:

confettiView.stop(clear: true)

Animation Status

To check whether the confetti animation is active, get the confettiView.animating property.

Styles

LBConfettiView contains four built-in confetti styles, .confetti, .diamond, .star and .triangle. To use these:

confettiView.style = .confetti
confettiView.style = .diamond
confettiView.style = .star
confettiView.style = .triangle

To use a custom image template for the confetti, use the .customImage style

confettiView.type = .customImage(UIImage(named: "customImage"))

Colors

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

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

Scale

Two confetti sizes are built-in: .small and .large. Using .auto, the default, will use the large scale on iPads and the small scale on other iOS devices.

confettiView.scale = .auto

A manual scale can also be provided as a CGFloat using .custom

confettiView.scale = .custom(0.8)

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

Installation

LBConfettiView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'LBConfettiView'

LBConfettiView can also be installed manually. Just download and drop the Sources folder in your project. Alternatively, add LBConfettiView.xcodeproj to your workspace and embed the framework binary.

Credit

Inspired by SAConfettiView by Sudeep Agarwal, which this was originally a modernised reimplementation of.

Author

Lachlan Bell <[email protected]>

Contributing

Contributions are welcome, see the CONTRIBUTING for more details.

Latest podspec

{
    "name": "LBConfettiView",
    "version": "1.0.0",
    "summary": "ud83cudf89 Smart Confetti View for iOS",
    "homepage": "https://github.com/lachlanbell/LBConfettiView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "lachlanbell": "[email protected]"
    },
    "source": {
        "git": "https://github.com/lachlanbell/LBConfettiView.git",
        "tag": "1.0.0"
    },
    "swift_version": "4.2",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "LBConfettiView/Sources/*.{swift,h}",
    "resources": "LBConfettiView/Assets/*.xcassets"
}

Pin It on Pinterest

Share This