CRParticleEffect
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
Cleveroad YouTube Channel in HD quality:
Watch the animation of Particle Effect onInstallation
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 imagesNSArray<UIImage *>
:CRParticleEffectLayer *layer = [[CRParticleEffectLayer alloc] initWithImages:@[...]];
Note: By default
CRParticleEffectLayer
scales images respecting[UIScreen mainScreen].scale
. Set layer'scontentScale
to change this behavior. -
ConfigCAEmitterCell
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'scolor
propertyparticleEffectLayer.color = [[UIColor redColor] colorWithAlphaComponent:0.75f]
-
-
CRMagicPanGestureRecognizer
- Supports storyboards;
- Set
minimumNumberOfTouches
andmaximumNumberOfTouches
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
'scontentScale
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 [email protected] (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.