如何在iPhone中的多行uilabel中加粗特定单词?

时间:2012-10-16 12:11:09

标签: iphone uilabel

  

可能重复:
  UILabel text Issue in iphone

我有这样的文字, 例: 优惠详情:如果用户从fb登记将获得20%的折扣,如果在Twitter上分享此优惠将获得企业30%的折扣。

我在上面的示例中我想提供'提供详细信息'只有大胆的其余文字,我想要定期。 我是如何实现这一目标的,我应用很多方法实现这一目标但却无法为此获得适当的解决方案。请帮助我实现这一目标。

1 个答案:

答案 0 :(得分:0)

在单一标签中,如果您希望您可以执行以下操作以使特定标签变为粗体,则不可能代替此标签。

 UILabel* myBoldlabel= [[UILabel alloc] init];
 myBoldlabel.text=@"Offer Details"; 
 myBoldlabel.font = [UIFont boldSystemFontOfSize:16.0f];
 UILabel* finalLabel=[[UILabel alloc] init];
 finalLabel.text=[NSString stringWithFormat:@"%@:,if users checkin from fb will get 20%  discount and if share the this offers on twitter will get 30 % discount from businesses",myBoldlabel];// You can place %@ anywhere in the sentence...
 finalLabel.numberOfLines=2;

如果您愿意应用任何特定字体,您也可以添加这种方式 - :

myBoldlabel.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:18];

希望这会对你有所帮助。