私はスイフト3からスウィフト4に移行しています。私はラベルに非常に特殊なテキストプロパティを与えているUILabelsを持っています。私は、strokeTextAttributesが初期化されているときに 'オプション値をアンラップしている間に'予期せず見つからないnil 'エラーを受け取っています。私は率直になるために完全に失われています。Swift 4ラベル属性
swift 3のthe strokeTextAttributesは[String:Any]でしたが、私がそれを以下に変更するまでエラーをスローしました。
let strokeTextAttributes = [
NSAttributedStringKey.strokeColor.rawValue : UIColor.black,
NSAttributedStringKey.foregroundColor : UIColor.white,
NSAttributedStringKey.strokeWidth : -2.0,
NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 18)
] as! [NSAttributedStringKey : Any]
chevronRightLabel.attributedText = NSMutableAttributedString(string: "0", attributes: strokeTextAttributes)
'NSAttributedStringKey.strokeColor.rawValue' =>' NSAttributedStringKey.strokeColor': あなたは以下のようなを使用する必要がありますか? – Larme
スウィフトは絶対的な悪夢であり、一般的なプログラミングのための主要なステップです。 – RunLoop