Swift 4 Label attributes

前端 未结 7 655
死守一世寂寞
死守一世寂寞 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)
        ]
    
    0 讨论(0)
提交回复
热议问题