Swift 4 Label attributes

前端 未结 7 653
死守一世寂寞
死守一世寂寞 2020-12-31 09:14

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

7条回答
  •  醉梦人生
    2020-12-31 10:02

    In Swift 4.x, this should look like :

            let strokeTextAttributes: [NSAttributedStringKey: Any] = [
            NSStrokeColorAttributeName: UIColor.black,
            NSForegroundColorAttributeName : UIColor.white,
            NSStrokeWidthAttributeName : -2.0,
            NSFontAttributeName : UIFont.boldSystemFont(ofSize: 18)
        ]
    

提交回复
热议问题