Not able to set custom fonts in WatchKit

2019-02-15 22:58发布

I am trying to set Roboto font and have added as target for watch kit extension, but it is still coming as nil. Can we set custom fonts in watch kit.

2条回答
相关推荐>>
3楼-- · 2019-02-15 23:44

Its worked for me.. Using following Codes.

Add the custom Font to both WatchKit Extension and WatchKit App target Info.plist

enter image description here

Now you write the code following way,

   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];
查看更多
登录 后发表回答