首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在NSAttributedString中IOS7中的Kerning失败

为什么在NSAttributedString中IOS7中的Kerning失败
EN

Stack Overflow用户
提问于 2013-10-08 16:37:42
回答 1查看 1.8K关注 0票数 1

我的应用程序有一个UILabel,格式为NSAttributedString,属性是:“NSKernAttributeName @1.9,”

  1. 当在运行iPad的IOS6上编译以下代码时,kern将按预期工作。
  2. 在运行iPad的IOS7上编译时,不会发生核化。

我已经在苹果开发者的网站上注册了Bug。#15108371 -还没有回应

代码语言:javascript
复制
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;
EN

回答 1

Stack Overflow用户

发布于 2013-10-30 21:21:33

好的。我也有同样的问题(见上面的评论)。这取决于字体(我也使用了快递)。由于一些奇怪的原因,Courier不支持kerning (在iOS7!)。使用CourierNewPSMT,一切都按预期工作,.至少对我来说。

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19253442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档