Skip to content

Cleveroad/CRParticleEffect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRParticleEffect Awesome

A CocoaPod that simplifies creation of particle effects. Supplied with UIPanGestureRecognizer subclass.

We know how to add some visual allure to your mobile app and can't wait to share with you. Meet new open-source library for iOS applications created by Cleveroad. CRParticleEffect function will make any pan touch visually attractive and memorable by adding unique particle effect. To know all the advantages of CRParticleEffect library and find out how to implement it into your app, read our blog post - How we created Particle Effect for iOS apps

Watch the animation of Particle Effect on Cleveroad YouTube Channel in HD quality:

Particle Effect for iOS by Cleveroad

Installation

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

pod "CRParticleEffect"

and run pod install in terminal.

#import <CRparticleEffect/CRParticleEffect.h>

Usage

  • CRParticleEffectLayer

    • Init with array of images NSArray<UIImage *>:
      CRParticleEffectLayer *layer = [[CRParticleEffectLayer alloc] initWithImages:@[...]];

      Note: By default CRParticleEffectLayer scales images respecting [UIScreen mainScreen].scale. Set layer's contentScale to change this behavior.

    • Config CAEmitterCell for every image in array:
      CRParticleEffectLayer *layer =
      [[CRParticleEffectLayer alloc] initWithImages:@[...]
                             emitterCellConfigBlock:^(CAEmitterCell * _Nonnull emitterCell, NSInteger index) {
         emitterCell.birthRate = 10 * (index + 1);
      }];
    • Set color for all particle effect's cells with layer's color property
      particleEffectLayer.color = [[UIColor redColor] colorWithAlphaComponent:0.75f]
  • CRMagicPanGestureRecognizer

    • Supports storyboards;
    • Set minimumNumberOfTouches and maximumNumberOfTouches to limit number of active particle effects.
    • Implement CRMagicPanGestureRecognizerDelegate to customize particle effects behavior.
  • CRMagicPanGestureRecognizerDelegate

    - (CRParticleEffectLayer *)gestureRecognizer:(CRMagicPanGestureRecognizer *)gestureRecognizer
                     particleEffectLayerForTouch:(UITouch *)touch
                                       withIndex:(NSUInteger)index
    {
        //Supply particleEffectLayer for each new touch with index
        return [[CRParticleEffectLayer alloc] initWithImages:@[self.images[index]]];
    }
    
    - (void)gestureRecognizer:(CRMagicPanGestureRecognizer *)gestureRecognizer
    willShowParticleEffectLayer:(CRParticleEffectLayer *)particleEffectLayer
                     forTouch:(UITouch *)touch
                    withIndex:(NSUInteger)index
    {
        //Change particles color for every touch with index
        particleEffectLayer.color = self.colors[index];
    }
    
    - (void)gestureRecognizer:(CRMagicPanGestureRecognizer *)gestureRecognizer
    willMoveParticleEffectLayer:(CRParticleEffectLayer *)particleEffectLayer
                     forTouch:(UITouch *)touch withIndex:(NSUInteger)index
    {
        //Update particle effect's attributes during panning (dragging) for specific touch with index
    }

Custom particle images

  • Use white images with transparent background;
  • If you do not supply multiple resolutions set CRparticleEffectLayer's contentScale to 1.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Support

If you have any questions, please contact us for support at info@cleveroad.com (email subject: «CRParticleEffect support.»)
or
Use our contacts:
Cleveroad.com
Facebook account
Twitter account
Youtube account
Google+ account
LinkedIn account
Dribbble account

License

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

About

A CocoaPod that simplifies creation of the particle effects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published