为什么在IOS7中对于NSAttributedString,Kerning失败

时间:2013-10-08 16:37:43

标签: ios7

我的应用程序将UILabel格式化为NSAttributedString 属性:'NSKernAttributeName @ 1.9,'

  1. 当在运行IOS6的iPad上编译以下代码时,kern按预期工作。
  2. 在运行IOS7的iPad上编译时,不会出现字距调整。
  3. 我已经在Apple Developer网站上提交了Bug。 #15108371 - 还没有回复

    NSString *formattedNumber;
    NSNumber *scoreNum = [[NSNumber alloc] initWithLongLong:thisScore];
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    formatter.numberStyle = NSNumberFormatterPadBeforeSuffix;
    formatter.formatWidth = 10;
    formatter.paddingCharacter = @"0";
    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    formatter.usesGroupingSeparator = NO;
    formattedNumber = [formatter stringFromNumber:scoreNum];
    
    //Creat atributed string of formated number.
    NSShadow *textShadow = [[NSShadow alloc] init];
    textShadow.shadowColor = [UIColor colorWithRed:0.5 green:0.7 blue:1 alpha:1.0];
    textShadow.shadowBlurRadius = 5.0;
    textShadow.shadowOffset = CGSizeMake(0,0);
    
    NSAttributedString  *pHighScoreStyle = [[NSAttributedString alloc] initWithString:formattedNumber attributes: @{
                 NSFontAttributeName: [UIFont fontWithName:@"courier" size:16],
      NSForegroundColorAttributeName: [UIColor colorWithRed:0.6 green:0.8 blue:1.0 alpha:0.8],
                 NSKernAttributeName: @1.9,
                NSShadowAttributeName: textShadow    }   ];
    
    //Change the disply value.
    runningScore.attributedText = pHighScoreStyle;
    

1 个答案:

答案 0 :(得分:2)

行。我遇到了同样的问题(见上面的评论)。这取决于字体(我也使用Courier)。出于某些奇怪的原因,Courier不支持字距调整(在iOS7中!)。 使用CourierNewPSMT,一切都按预期工作 ....至少对我而言。

顺便说一句:这是iphone上很好的字体列表: http://iosfonts.com/