Skip to content

Commit

Permalink
made use of setText:withCompletionBlock: within the simpler `setTex…
Browse files Browse the repository at this point in the history
…t:`; renamed the completion block to be more descriptive;
  • Loading branch information
TomKnig committed Nov 11, 2014
1 parent 1c38204 commit 9861aaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
19 changes: 6 additions & 13 deletions Classes/TOMSMorphingLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define kTOMSKernFactorAttributeName @"kTOMSKernFactorAttributeName"

@interface TOMSMorphingLabel (){
void (^_block)(void);
void (^_setTextCompletionBlock)(void);
}

@property (readonly, nonatomic, assign) NSUInteger numberOfAttributionStages;
Expand Down Expand Up @@ -253,18 +253,11 @@ - (NSArray *)deletionRanges

- (void)setText:(NSString *)text
{
if (self.isMorphingEnabled) {
self.nextText = text ? text : @"";
if (self.displayLinkDuration > 0) {
[self beginMorphing];
}
} else {
super.text = text;
}
[self setText:text withCompletionBlock:nil];
}

- (void)setText:(NSString*) text withCompletionBlock:(void (^)(void))block{
_block = block;
_setTextCompletionBlock = block;
if (self.isMorphingEnabled) {
self.nextText = text ? text : @"";
if (self.displayLinkDuration > 0) {
Expand Down Expand Up @@ -414,9 +407,9 @@ - (void)endMorphing
[self beginMorphing];
}
else{
if(_block != nil){
_block();
_block = nil;
if(_setTextCompletionBlock != nil){
_setTextCompletionBlock();
_setTextCompletionBlock = nil;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ - (void)viewDidLoad {
[label setText:@"Test" withCompletionBlock:^{
NSLog(@"First label animation completed");
}];

[self performSelector:@selector(toggleTextForLabel:) withObject:label afterDelay:2];
}

Expand Down

0 comments on commit 9861aaf

Please sign in to comment.