Take a look at the API on NSAttributedString - it allows you to create a string that indicates the parts of the string that should be written using specific text styles and / or fonts. The resulting object can be used instead of a simple string with UILabel (and other user interface elements) by setting the label attributedText property instead of the usual text property.
To make only the word "bold" appear in 18 dot bold , try the following:
var label = UILabel() let bigBoldFont = UIFont.boldSystemFontOfSize(18.0) var attrString = NSMutableAttributedString(string: "This text is bold.") attrString.addAttribute(kCTFontAttributeName, value: bigBoldFont, range: NSMakeRange(13, 4)) label.attributedText = attrString
The specified range defines the portion of the string to which the assigned name should apply (in this case, the font). And note that the parameters for NSMakeRange are the starting position of the character and the length of the range.
source share