custom font becomes a nil value in swift 3

Viewed 3790

I want to set attributedstring to my UILabel. So I defined the attributes in this way.

let attribute1:[String:Any]=[
        NSForegroundColorAttributeName: UIColor.init(colorLiteralRed: 120.0/255, green: 173.0/255, blue: 194.0/255, alpha: 1.0),
        NSFontAttributeName:UIFont.init(name: "Bariol_Bold", size: 15.0)!]
let attributedStringGreeting=NSAttributedString.init(string: welcomeMessage, attributes: attribute1)

but I am getting this error in the line:

NSFontAttributeName:UIFont.init(name: "Bariol_Bold", size: 15.0)!]

Does that mean my custom font is not taking? But when I set the font from IB it shows.

fatal error: unexpectedly found nil while unwrapping an Optional value

How can I solve this issue? Please help me.

enter image description here

enter image description here

3 Answers
Related