不支持 TTStyledTextLabel 字体大小
我尝试使用 Three20 框架附带的 TTCatelog 示例,在 StyledTextTestController 上,不知何故,字体大小根本不被尊重,它们都显示为相同的字体和大小。有什么特殊设置可以打开它吗?
以下是示例代码中的内容,据称该代码会将“bah”显示为大文本,将“humhug”显示为小文本。但在模拟器中,它们都是一样的。
@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)init {
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];
}
@结尾
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)init {
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论