Can I set the `attributedText` property of `UILabel`

后端 未结 8 919
长发绾君心
长发绾君心 2020-12-22 21:52

Can I set the attributedText property of a UILabel object? I tried the below code:

UILabel *label = [[UILabel alloc] init];
label.a         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 22:25

    For people using swift, here's a one-liner:

    myLabel.attributedText = NSMutableAttributedString(string: myLabel.text!, attributes: [NSFontAttributeName:UIFont(name: "YourFont", size: 12), NSForegroundColorAttributeName: UIColor.whiteColor()])
    

提交回复
热议问题