diff --git a/JRMFloatingAnimation.podspec b/JRMFloatingAnimation.podspec index 237b435..0d26ea8 100644 --- a/JRMFloatingAnimation.podspec +++ b/JRMFloatingAnimation.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "JRMFloatingAnimation" - s.version = "0.1.2" + s.version = "0.1.3" s.summary = "A floating animation that can be used for bubbles, clouds, music notes, or whatever your heart desires." # This description is used to generate tags and improve search results. diff --git a/Pod/Classes/JRMFloatingAnimationView.h b/Pod/Classes/JRMFloatingAnimationView.h index 0b19fa4..640d978 100644 --- a/Pod/Classes/JRMFloatingAnimationView.h +++ b/Pod/Classes/JRMFloatingAnimationView.h @@ -48,7 +48,7 @@ typedef NS_ENUM(NSInteger, JRMFloatingShape) { */ @property CGFloat animationWidth; /** - * Gives the impression of the images "popping" + * Gives the impression of the images "popping" * before they are removed from the view. * Default NO. */ @@ -99,11 +99,15 @@ typedef NS_ENUM(NSInteger, JRMFloatingShape) { * Must init the animation with a starting point, or you may experience unintended behavior. */ - (id)initWithStartingPoint:(CGPoint)startingPoint; -/** +/** * The images that make up the floating objects. * At least one SQUARE image must be added. */ - (void)addImage:(UIImage *)image; +/** + * Remove all images. + */ +- (void)removeAllImages; /** * "Release" a floating object. diff --git a/Pod/Classes/JRMFloatingAnimationView.m b/Pod/Classes/JRMFloatingAnimationView.m index fb679bd..aacae69 100644 --- a/Pod/Classes/JRMFloatingAnimationView.m +++ b/Pod/Classes/JRMFloatingAnimationView.m @@ -42,20 +42,24 @@ - (void)addImage:(UIImage *)image { [self.images addObject:image]; } +- (void)removeAllImages { + [self.images removeAllObjects]; +} + - (void)animate { - + if (self.firstAnimation) { if (self.animationWidth) { self.customWidth = YES; } } - + if (self.minFloatObjectSize > self.maxFloatObjectSize) { self.maxFloatObjectSize = self.minFloatObjectSize; } - + CGFloat size = [self randomFloatBetween:self.minFloatObjectSize and:self.maxFloatObjectSize]; - + if (!self.customWidth) { switch (self.floatingShape) { case JRMFloatingShapeCurveLeft: { @@ -74,24 +78,24 @@ - (void)animate { } break; } } - + UIImage *image = [self.images objectAtIndex:[self randomIndex:[self.images count]]]; - + JRMFloatingImageView *floatingImageView = [[JRMFloatingImageView alloc] initWithImage:image]; - + if (self.varyAlpha) { floatingImageView.alpha = [self randomFloatBetween:.1 and:1]; } - + if (self.startingPointWidth) { CGFloat w = [self randomFloatBetween:(self.startingPoint.x - (self.startingPointWidth / 2)) and:(self.startingPoint.x + (self.startingPointWidth / 2))]; [floatingImageView setFrame:CGRectMake(w, self.startingPoint.y - (size / 2), size, size)]; } else { [floatingImageView setFrame:CGRectMake(self.startingPoint.x, self.startingPoint.y - (size / 2), size, size)]; } - + floatingImageView.delegate = self; - + [self addSubview:floatingImageView]; [floatingImageView start]; self.firstAnimation = NO;