无法在WatchKit中设置自定义字体

Moh*_*ani 2 uifont ios apple-watch watchkit

我正在尝试设置Roboto字体,并已添加为手表套件扩展的目标,但它仍然是零.我们可以在手表套件中设置自定义字体.

Yan*_*eez 7

它对我有用..使用以下代码.

将自定义Font添加到WatchKit ExtensionWatchKit App目标Info.plist

在此输入图像描述

现在你按照以下方式编写代码,

   NSMutableAttributedString *attString =[[NSMutableAttributedString alloc]
     initWithString: @"Yano rocks! Always"];

    [attString setAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Open Sans" size:20.0]} range:NSMakeRange(0, attString.string.length)];

    [self.loadingLabel setAttributedText:attString];
Run Code Online (Sandbox Code Playgroud)

  • 请记住,虽然可以在主监视应用程序中使用自定义字体,但它们不能在Glances或Notifications视图中使用. (2认同)