我已经阅读了关于这个主题的所有问题和答案,它们似乎都适用于自定义字体,而不是系统字体。
我使用界面生成器并在 SpriteKit 场景中有一个 SKLabelNode,我将字体更改为“Lithos Pro”。它在 IB 中正确显示,但在模拟器中运行时会显示通用字体。我还以编程方式将 UITextField 添加到场景中,尝试使用同样不起作用的字体。
据我了解,这包含在 NSFont 包中,但只是为了确认我将 TTF 文件添加到项目中并将它们包含在我的目标资源中。还是不行。
想法?
nameField = UITextField(frame: CGRect(x: view.center.x - 150,y:view.center.y - 25,width: 300, height: 50))
nameField.font = UIFont(name: "Lithos Pro Regular", size: 25) //I've tried 'Lithos Pro, LithosPro, and Lithos Pro Regular'
nameField.textAlignment = .center
nameField.borderStyle = UITextBorderStyle.roundedRect
nameField.autocorrectionType = UITextAutocorrectionType.no
nameField.keyboardType = UIKeyboardType.default
nameField.returnKeyType = UIReturnKeyType.done
nameField.clearButtonMode = UITextFieldViewMode.whileEditing;
nameField.contentVerticalAlignment = UIControlContentVerticalAlignment.center
view.addSubview(nameField)