当使用NSKernAttributeName时,它会在每一行的末尾放置一个空格,有什么办法可以解决这个问题吗?我可以将属性设置在以下范围内:NSRange(location:0,length:self.text!.characters.count-1)但我不想为每一行都设置这个。这是我正在使用的Playground中的测试代码//:Playground-noun:aplacewherepeoplecanplayimportUIKitimportXCPlaygroundvartext="Hello,playground\nhowareyou?"letparagraphStyle=NSMu
当使用NSKernAttributeName时,它会在每一行的末尾放置一个空格,有什么办法可以解决这个问题吗?我可以将属性设置在以下范围内:NSRange(location:0,length:self.text!.characters.count-1)但我不想为每一行都设置这个。这是我正在使用的Playground中的测试代码//:Playground-noun:aplacewherepeoplecanplayimportUIKitimportXCPlaygroundvartext="Hello,playground\nhowareyou?"letparagraphStyle=NSMu
iOS部署目标:iOS9.3,基础SDK:最新的iOS(iOS11.0),Xcode9测试版4,swift4以下代码在Swift3、Xcode8中构建和运行:letkern=(CTRunGetAttributes(run)as?[String:Any])?[NSKernAttributeName]as?CGFloat??0但是,Swift4迁移器将其转换为:letkern=(CTRunGetAttributes(run)as?[String:Any])?[NSAttributedStringKey.kern]as?CGFloat??0Xcode9现在提示:Cannotsubscript
当我使用drawInRect:withAttributes:并传入带有NSTextAlignmentCenter的段落样式和NSKernAttributeName的非零值时,字符串没有正确居中。我做错了什么还是这是预期的行为?有解决方法吗?截图:您可以清楚地看到顶部文本没有正确居中。我的演示代码:-(void)drawRect:(CGRect)rect{//DrawingcodeUIFont*font=[UIFontsystemFontOfSize:15.0];[selfdrawString:@"88"inRect:rectfont:fonttextColor:[UIColorblac