Giter Club home page Giter Club logo

confetti's Introduction

Life360 Confetti

Why Confetti? Because here at Life360 we like to celebrate our users and their accomplishments. We believe products should celebrate users and give them a gift when they've accomplished something.

That's why we've created L360Confetti.

Confetti!! Gif thanks to gfycat.com

Get Example Project

Installation

Requirement: iOS 7.0 or above because this class relies heavily on UIDynamics

CocoaPods Installation

Add the following line to your podfile:

pod 'L360Confetti', :git => 'https://github.com/life360/confetti.git'

And then run pod install

..Or Manual Installation

Copy the contents of L360Confetti folder located in iOS/L360Confetti

Using L360Confetti

L360ConfettiArea is a view that you add to your view controller in which the confetti will display.

Note: The L360ConfettiArea is a UIView that retains the default settings of UIViews where userInteractionEnabled is YES (so no click-through) and layer.masksToBounds is NO (So confetti can pop up anywhere1) by default.

1 The confetti disappears at the bottom of the frame for the L360ConfettiArea. The confetti are garbage collected so that you can explode as much confetti into the area as you want.

Initialization

#import "L360ConfettiArea.h"

// Wherever youre going to initialize it
L360ConfettiArea *confettiArea = [[L360ConfettiArea alloc] initWithFrame:confettiFrame];

Burst Confetti

L360Confetti is currently designed to burst confetti from a single point on the view. Use the following to accomplish this.

// Signature
- (void)burstAt:(CGPoint)point confettiWidth:(CGFloat)confettiWidth numberOfConfetti:(NSInteger)numberConfetti

// Use
[confettiArea burstAt:[self.view convertPoint:tapPoint toView:self.confettiView] confettiWidth:10.0 numberOfConfetti:15];

Note for Confetti Width: Currently to give the confetti some nice fluttering effect, using layer animations for rotations along different axis, thus the confetti has to be a square.

Confetti Colors

To control the colors of the confetti, you need to provide the L360ConfettiArea's delegate method an array of colors.

confettiArea.delegate = self;

// ...
- (NSArray *)colorsForConfettiArea:(L360ConfettiArea *)confettiArea
{
    return @[[UIColor blueColor], [UIColor redColor], [UIColor purpleColor]];
}

Issues and Help

If the community could help us figure out a few of the problems with the L360Confetti that would be great. Following is a list of the issues we're currently facing:

License

L360Confetti is available under the Apache License Version 2.0

confetti's People

Contributors

mmislam101 avatar joshuarcher avatar ricsantos avatar batkov avatar

Watchers

James Cloos avatar Sarath Raveendran 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.