TTStyledTextLabel offset between link and regular text when changing from default font
- by Guy Ephraim
I'm using Three20 TTStyledTextLabel and when I change the default font (Helvetica) to something else it creates some kind of height difference between links and regular text
The following code demonstrate my problem:
#import <Three20/Three20.h>
@interface TestController : UIViewController {
}
@end
@implementation TestController
-(id)init{
self = [super init];
TTStyledTextLabel* label = [[[TTStyledTextLabel alloc] initWithFrame:CGRectMake(0, 0, 320, 230)] autorelease];
label.text = [TTStyledText textFromXHTML:@"<a href=\"aa://link1\">link</a> text" lineBreaks:YES URLs:YES];
[label setFont:[UIFont systemFontOfSize:16]];
[[self view] addSubview:label];
TTStyledTextLabel* label2 = [[[TTStyledTextLabel alloc] initWithFrame:CGRectMake(0, 230, 320, 230)] autorelease];
label2.text = [TTStyledText textFromXHTML:@"<a href=\"aa://link1\">link2</a> text2" lineBreaks:YES URLs:YES];
[label2 setFont:[UIFont fontWithName:@"HelveticaNeue" size:16]];
[[self view] addSubview:label2];
return self;
}
@end
In the screen shot you can see that the first link is aligned and the second one isn't
How do I fix it? I think there is a bug in the TTStyledTextLabel code...