【发布时间】:2012-12-28 11:41:04
【问题描述】:
我有一个由 - 组成的字符串
lblWithText.backgroundColor = [UIColor clearColor];
lblWithText.textColor = [UIColor blackColor];
lblWithText.font = [UIFont fontWithName:@"Helvetica" size:12.0];
lblWithText.text = [NSString stringWithFormat:@"Blah1:blah-blah%d. Blah2:-%d%%", [currentCoupon.couponPrice intValue],[currentCoupon.couponDiscountPercent intValue]];
请告诉我该怎么做,“Blah2:-%d%%”是Bolden? 提前致谢
【问题讨论】:
-
你的代码最后一行不完整,请补全。
-
如果你想加粗字体,只需将 Helvetica 替换为 @"HelveticaBold" 或 @"Helvetica Bold" ,这两种都可以
-
谢谢,但我只需要粗体“Blah2:-%d%%”,而不是完整的字符串..而且我不明白该怎么做。
-
如果你想让字符串的一部分加粗,你将不得不使用两个不同的标签或 UIWebview。
-
还有一个替代方案。您可以选择使用 NSAttributedString 代替。使用两个标签不是一个好的选择
标签: iphone objective-c uilabel