我向我的项目添加了自定义字体,并确保它位于构建阶段的“复制捆绑资源”中。我还确保它已正确添加到 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")
我得到错误:
fatal error: unexpectedly found nil while unwrapping an Optional value
为线
NSFontAttributeName : UIFont(name: "NeutraText-Bold", size: 17)!
最佳答案
关于ios - 向项目添加自定义字体但是当我尝试使用它们时我得到一个 "fatal error: unexpectedly found nil while unwrapping an Optional value",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43925353/