2

UILable と UIButton の ios でカスタム フォントのカーニングを使用できますか?

以下の方法は機能しません。カーニングはシステム フォントでは機能しますが、カスタム フォントでは機能しません。誰かが問題の解決を手伝ってくれますか?

NSMutableAttributedString *attributedString =
   [[NSMutableAttributedString alloc] initWithString:text attributes:
       @{
          NSFontAttributeName : [UIFont fontWithName:@"BebasNeue Bold" size:25],
          NSForegroundColorAttributeName : [UIColor redColor]
     }];

   [attributedString addAttribute:NSKernAttributeName
       value:[NSNumber numberWithFloat:kerning]
       range:NSMakeRange(0, [text length])];
   [self setAttributedText:attributedString];
4

1 に答える 1

4

これを試すことができます。それは役立つかもしれません。

NSMutableAttributedString *attributedString;
attributedString = [[NSMutableAttributedString alloc] initWithString:@"Please test this text"];
[attributedString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(10, 5)];
[self.label setAttributedText:attributedString];

より多くの解決策については、次のリンクを確認してください

iPhone UILabel でカーニングを設定する方法

これがお役に立てば幸いです。

于 2015-08-14T07:33:22.613 に答える