TTStyledTextLabel offset between link and regular text when changing from default font

Posted by Guy Ephraim on Stack Overflow See other posts from Stack Overflow or by Guy Ephraim
Published on 2010-02-14T15:51:02Z Indexed on 2010/05/14 10:24 UTC
Read the original article Hit count: 778

Filed under:
|

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

Screen Shot

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...

© Stack Overflow or respective owner

Related posts about three20

Related posts about iphone