Permalink
Browse files

Make sure the barber pole stays animating even if it has previously b…

…een removed from it's superview but hasn't been told to stop.
  • Loading branch information...
1 parent 6123195 commit 9c156faaba11faba8444fe332fa5859df458433e Danny Greg committed May 25, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/UIKit/TUIProgressBar.m
@@ -254,6 +254,8 @@ - (CGPoint)farRightAnimatingPosition
- (void)setIndeterminate:(BOOL)indeterminate
{
+ static NSString *animationKey = @"GHUIBarberPoleAnimation";
+
_indeterminate = indeterminate;
if (!indeterminate) {
@@ -262,8 +264,13 @@ - (void)setIndeterminate:(BOOL)indeterminate
return;
}
- if (self.animationView != nil)
- return; //We are already animating a barber pole
+ if (self.animationView != nil) { //We already have an animation view added but the progress bar could have been taken off screen, so stopped animating
+ NSArray *animationKeys = self.animationView.layer.animationKeys;
+ if (animationKeys == nil || ![animationKeys containsObject:animationKey]) {
+ [self.animationView.layer addAnimation:[self basicAnimationForView:self.animationView animationKey:animationKey] forKey:animationKey];
+ }
+ return;
+ }
// Animation container
TUIView *animationClippingView = [[TUIView alloc] initWithFrame:[self fillRect]];
@@ -303,7 +310,6 @@ - (void)setIndeterminate:(BOOL)indeterminate
[self addSubview:animationClippingView];
[animationClippingView addSubview:self.animationView];
- NSString *animationKey = @"GHUIBarberPoleAnimation";
[self.animationView.layer addAnimation:[self basicAnimationForView:self.animationView animationKey:animationKey] forKey:animationKey];
[self setNeedsDisplay];

0 comments on commit 9c156fa

Please sign in to comment.