相关疑难解决方法(0)

Xcode 8自定义字体未显示在界面构建器中

我想在我的iOS应用程序中使用自定义字体(Bebas Neue).我采取的步骤是:

  1. 将.otf文件复制到项目中.
  2. 确认.otf文件已将项目设置为目标.
  3. 在plist中的"应用程序提供的字体"中添加了.otf文件.
  4. 在Build Phases中,.otf文件位于"Copy Bundle Resources"中.
  5. 在我的Mac上安装字体.
  6. 尝试打印出所有可用的字体,但我看不到自定义字体.

我用过的代码:

for name in UIFont.familyNames() {
  println(name)
  if let nameString = name as? String
  {
    println(UIFont.fontNamesForFamilyName(nameString))
  }
}
Run Code Online (Sandbox Code Playgroud)
  1. 试图在代码中设置字体,它工作.

我用过的代码:

textLabel?.font = UIFont(name: "BebasNeueRegular", size: 14)
Run Code Online (Sandbox Code Playgroud)
  1. 但是我不能在界面构建器中设置它.任何的想法?

截图:

字形 字体名录

xcode custom-font ios swift

44
推荐指数
4
解决办法
2万
查看次数

标签 统计

custom-font ×1

ios ×1

swift ×1

xcode ×1