Permalink
Browse files

Shimmer label will reanimate after the app is reopened.

  • Loading branch information...
1 parent d682038 commit f8f773d5dafaf85a34c89f105e00f47da1a216f7 @devinross committed Feb 22, 2014
Showing with 19 additions and 3 deletions.
  1. +19 −3 src/TapkuLibrary/TKShimmerLabel.m
@@ -50,10 +50,19 @@ - (id) initWithFrame:(CGRect)frame{
self.textHighlightLayer.endPoint = CGPointMake(1.0, 0);
self.layer.mask = self.textHighlightLayer;
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(applicationDidBecomeActive:)
+ name:UIApplicationDidBecomeActiveNotification object:nil];
+
return self;
}
+- (void) dealloc{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
-- (void) willMoveToWindow:(UIWindow *)newWindow{
+- (void) _startShimmerAnimation{
+
+ if(!self.superview) return;
[self.textHighlightLayer removeAllAnimations];
CGFloat x = self.textHighlightLayer.frame.size.width/2.0f;
@@ -63,9 +72,16 @@ - (void) willMoveToWindow:(UIWindow *)newWindow{
animation.fromValue = @(-x + self.frame.size.width);
animation.duration = 4.0f;
[self.textHighlightLayer addAnimation:animation forKey:@"position.x"];
-
}
+- (void) applicationDidBecomeActive:(id)sender{
+
+ [self _startShimmerAnimation];
+
+}
+- (void) willMoveToWindow:(UIWindow *)newWindow{
+ [self _startShimmerAnimation];
+}
-@end
+@end

0 comments on commit f8f773d

Please sign in to comment.