Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion JRMFloatingAnimation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions Pod/Classes/JRMFloatingAnimationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
Expand Down
24 changes: 14 additions & 10 deletions Pod/Classes/JRMFloatingAnimationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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;
Expand Down