Skip to content

Commit

Permalink
- restart animation
Browse files Browse the repository at this point in the history
- cleanup code
  • Loading branch information
cbess committed Dec 22, 2015
1 parent f675efe commit 9062820
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions CBAutoScrollLabel/CBAutoScrollLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ - (void)setBounds:(CGRect)bounds {
[self didChangeFrame];
}

- (void)didMoveToWindow {
[super didMoveToWindow];

if (self.window) {
[self scrollLabelIfNeeded];
}
}

#pragma mark - Properties

- (UIScrollView *)scrollView {
Expand Down Expand Up @@ -221,7 +229,7 @@ - (CGSize)shadowOffset {
#pragma mark - Autolayout

- (CGSize)intrinsicContentSize {
return CGSizeMake(0.0f, [self.mainLabel intrinsicContentSize].height);
return CGSizeMake(0, [self.mainLabel intrinsicContentSize].height);
}

#pragma mark - Misc
Expand Down Expand Up @@ -279,7 +287,7 @@ - (void)scrollLabelIfNeeded {
[UIView animateWithDuration:duration delay:self.pauseInterval options:self.animationOptions | UIViewAnimationOptionAllowUserInteraction animations:^{
// adjust offset
self.scrollView.contentOffset = (doScrollLeft ? CGPointMake(labelWidth + self.labelSpacing, 0) : CGPointZero);
} completion: ^(BOOL finished) {
} completion:^(BOOL finished) {
_scrolling = NO;

// remove the left shadow
Expand Down Expand Up @@ -341,7 +349,7 @@ - (void)refreshLabels {
}
}

// bounds or frame has been changeds
// bounds or frame has been changed
- (void)didChangeFrame {
[self refreshLabels];
[self applyGradientMaskForFadeLength:self.fadeLength enableFade:self.scrolling];
Expand Down

0 comments on commit 9062820

Please sign in to comment.