Skip to content

Commit 9db9468

Browse files
small refactoring
1 parent d07558c commit 9db9468

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

SecretAnimation/NTRViewController.m

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@ - (void)viewDidLoad
3030
self.textLabel1.alpha = 0;
3131
self.textLabel2.alpha = 0;
3232

33+
// this is based on the view hierarchy in the storyboard
34+
self.topLabel = self.textLabel2;
35+
self.bottomLabel = self.textLabel1;
36+
3337
NSString *mySecretMessage = @"This is a my replication of Secret's text animation. It looks like one fancy label, but it's actually two UITextLabels on top of each other! What do you think?";
3438

3539
self.numWhiteCharacters = 0;
3640

37-
NSAttributedString *initialAttributedText = [self randomlyFadedAttributedStringFromString:mySecretMessage];
38-
self.textLabel2.attributedText = initialAttributedText;
39-
40-
self.attributedString = [self randomlyFadedAttributedStringFromAttributedString:initialAttributedText];
41-
self.textLabel1.attributedText = self.attributedString;
41+
__block NSAttributedString *initialAttributedText = [self randomlyFadedAttributedStringFromString:mySecretMessage];
42+
self.topLabel.attributedText = initialAttributedText;
4243

4344
__weak NTRViewController *weakSelf = self;
4445
[UIView animateWithDuration:0.1 animations:^{
45-
weakSelf.textLabel2.alpha = 1;
46+
weakSelf.topLabel.alpha = 1;
4647
} completion:^(BOOL finished) {
47-
weakSelf.topLabel = self.textLabel2;
48-
weakSelf.bottomLabel = self.textLabel1;
48+
weakSelf.attributedString = [weakSelf randomlyFadedAttributedStringFromAttributedString:initialAttributedText];
49+
weakSelf.bottomLabel.attributedText = weakSelf.attributedString;
4950
[weakSelf performAnimation];
5051
}];
5152
}

0 commit comments

Comments
 (0)