Skip to content

Commit

Permalink
Fixed bug that inserted an additional space at the beginning of text
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Rodella committed Feb 29, 2012
1 parent d0d9a09 commit 18fd198
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Classes/TextBoxLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ - (id) initWithColor:(UIColor *)color width:(CGFloat)w height:(CGFloat)h padding

lines = [[NSMutableArray alloc] init];

int wc = 0;

for (NSString *word in words) {
NSString *eval = [wrappedText stringByAppendingFormat:@" %@", word];

NSString *eval = nil;

if (wc == 0) {
eval = word;
} else {
eval = [wrappedText stringByAppendingFormat:@" %@", word];
}

int size = [self calculateStringSize:eval];

// See if the text so far plus the new word fits the rect
Expand All @@ -56,9 +66,15 @@ - (id) initWithColor:(UIColor *)color width:(CGFloat)w height:(CGFloat)h padding
[lines addObject:[NSString stringWithString:wrappedText]];
[wrappedText setString:word];
} else {
[wrappedText appendFormat:@" %@", word];
if (wc > 0) {
[wrappedText appendString:@" "];
}
[wrappedText appendString:word];
}

wc++;
}

[lines addObject:[NSString stringWithString:wrappedText]];

totalPages = ceil((float)[lines count] / linesPerPage);
Expand Down

0 comments on commit 18fd198

Please sign in to comment.