If I create a label like this:
var label = UILabel(...)
label.text = first_name + ", " + age
self.view.addSubview(label)
How can I change the age of the label to bold, but keep the first_name normal weight?
If I create a label like this:
var label = UILabel(...)
label.text = first_name + ", " + age
self.view.addSubview(label)
How can I change the age of the label to bold, but keep the first_name normal weight?
You can use an attributed string. Here, the bold size is 15, but you can also change that point size if you want.
var age = "13"
var att = [NSFontAttributeName : UIFont.boldSystemFontOfSize(15)]
var boldAge = NSMutableAttributedString(string:age, attributes:att)
// Assigning to a UILabel
yourLabel.attributedText = boldAge
so now you would want to assign your text like this:
label.attributedText = first_name + ", " + boldAge