Xcode5 and iOS7: trailing whitespaces in strings in Localizable.strings not working anymore

[亡魂溺海] 提交于 2019-12-01 05:10:34

Perhaps you can try this workaround with NSMutableAttributedString which worked for me. The "." is put in place of the whitespace.

NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%i.", count]];


 [string addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,string.length-1)];

 [string addAttribute:NSForegroundColorAttributeName value:[UIColor clearColor] range:NSMakeRange(string.length-1,1)];

Have you tried the non breaking space character?

Ok, I am solving this issue by adding the label as a subview to a view and setting the width of the label a bit smaller that that of the view.

All styling, i.e. background image, animations etc. is done to the view, not the label. Not the KISS principle but it works.

Thanks anyway.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!