[英]I got an error “fatal error: unexpectedly found nil while unwrapping an Optional value” when I try to get a phone number in contact
[英]Added custom font to project but when I try and use them I get a “fatal error: unexpectedly found nil while unwrapping an Optional value”
我在項目中添加了自定義字體,並確保它在構建階段的“復制捆綁資源”中。 我還確保將其正確添加到plist文件中:
但是當我為占位符文本設置函數時:
let attributes = [
NSForegroundColorAttributeName: UIColor.white,
NSFontAttributeName : UIFont(name: "NeutraText-Bold", size: 17)!
]
func placeHolder(_ text: String) -> (NSAttributedString){
return NSAttributedString(string: text, attributes:attributes)
}
signUpTextField.attributedPlaceholder = placeHolder("Sign Up")
我得到錯誤:
致命錯誤:解開Optional值時意外發現nil
為線
NSFontAttributeName : UIFont(name: "NeutraText-Bold", size: 17)!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.