开发者

TTStyledTextLabel font size not honored

开发者 https://www.devze.com 2023-02-01 06:46 出处:网络
I tried with the TTCatelog sample comes with Three20 framework, on the StyledTextTestController, somehow the font size is not honored at all, they all showed as the same font and size. Is there any sp

I tried with the TTCatelog sample comes with Three20 framework, on the StyledTextTestController, somehow the font size is not honored at all, they all showed as the same font and size. Is there any special setting to turn that on?

The following is what there in the sample code, which supposedly will show the "bah" as large text, and "humhug" as small text. But in the emulator, they all the same.

@implementation TextTestStyleSheet

- (TTStyle*)largeText {
  return [TTTextStyle styleWithFont:[UIFont systemFontOfSize:32] next:nil];
}

- (TTStyle*)smallText {
  return [TTTextStyle styleWithFont:[UIFont systemFontOfSize:12] next:nil];
}

@end

@implementation StyledTextTestController

- (id)ini开发者_开发问答t {
  if (self = [super init]) {
    [TTStyleSheet setGlobalStyleSheet:[[[TextTestStyleSheet alloc] init] autorelease]];
  }
  return self;
}


- (void)loadView {
  [super loadView];

  NSString* kText = @"<span class=\"largeText\">bah</span> <span class=\"smallText\">humbug</span>";

  TTStyledTextLabel* label1 = [[[TTStyledTextLabel alloc] initWithFrame:self.view.bounds] autorelease];
  label1.text = [TTStyledText textFromXHTML:kText lineBreaks:YES URLs:YES];
  label1.contentInset = UIEdgeInsetsMake(10, 10, 10, 10);
  [label1 sizeToFit];
  [self.view addSubview:label1];
}

@end

0

精彩评论

暂无评论...
验证码 换一张
取 消