GithubHelp home page GithubHelp logo

lbconfettiview's Introduction

LBConfettiView

Build Status Version License Platform Swift Version PRs Welcome

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.

lbconfettiview's People

Contributors

lachlanbell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.