Not able to set custom fonts in WatchKit

前端 未结 2 511
Happy的楠姐
Happy的楠姐 2021-01-07 00:35

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条回答
  • 2021-01-07 00:55

    Yes, you can use custom fonts in WatchKit

    https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/TextandLabels.html

    0 讨论(0)
  • 2021-01-07 01:14

    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];
    
    0 讨论(0)
提交回复
热议问题