我的应用程序将UILabel格式化为NSAttributedString 属性:'NSKernAttributeName @ 1.9,'
我已经在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;
答案 0 :(得分:2)
行。我遇到了同样的问题(见上面的评论)。这取决于字体(我也使用Courier)。出于某些奇怪的原因,Courier不支持字距调整(在iOS7中!)。 使用CourierNewPSMT,一切都按预期工作 ....至少对我而言。
顺便说一句:这是iphone上很好的字体列表: http://iosfonts.com/