Xcode5 and iOS7: trailing spaces in lines in Localizable.strings no longer work

In my Localizable.strings, I define a line with trailing spaces like:

"%@ points " = "%@ Punkte "; 

This works fine in iOS6, but when run on the iOS7 emulator, the line is truncated and trailing spaces are removed.

Background: the line above is right-aligned in the label. I use spaces as a complement since I don't want to subclass UILabel or write a bunch of code for just one label.

I also tried using ASCII characters, but that also didn't work.

Any suggestions for a simple soul would be appreciated.

Thanks!

+6
source share
3 answers

Perhaps you can try this workaround with NSMutableAttributedString, which worked for me. "." It is placed instead of a space.

 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)]; 
+8
source

Have you tried the non-space character ?

0
source

Ok, I solve this problem by adding a label as a subview to the view and setting the label width a little less than the view.

All views, such as a background image, animation, etc., are performed only with the view, and not with the label. Not the KISS principle, but it works.

Thank you anyway.

0
source

Source: https://habr.com/ru/post/954245/


All Articles