I\'m moving from swift 3 to swift 4. I have UILabels that I am giving very specific text properties to the label. I\'m getting an \'unexpectedly found nil while unwrapping
if you want to change particular string value so that below answer is helpful you:-
let subStr = "Hello" let allStr = "Hello World"
let newStr = NSMutableAttributedString(string: allStr)
newStr.addAttribute(kCTFontAttributeName as NSAttributedStringKey, value: UIFont.init(customFont: .MyriadPro_R, withSize: 18)!, range: (allStr as NSString).range(of: subStr))
newStr.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.PrimaryColor, range: (allStr as NSString).range(of: subStr))
self.stateLbl.attributedText = newStr