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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, you can use custom fonts in WatchKit
https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/TextandLabels.html
回答2:
Its worked for me.. Using following Codes.
Add the custom Font to both WatchKit Extension and WatchKit App target Info.plist
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];