Answer the question
In order to leave comments, you need to log in
Why does UILabel spit on formatting?
Need to align multiple lines in an application.
The code itself:
subText = [NSString stringWithFormat:@"%3d%% - %@",subPercent,subfactor];
NSLog(@"%@",subText);
[label setText:subText];
Answer the question
In order to leave comments, you need to log in
Looks like the problem is in "%3d%%".
When the number is two-digit, a space is added. When unambiguous, two spaces.
Try to output a number with %d
UPD. The mistake was that it was designed for monospace fonts (in which the width of all characters, including spaces, are equal).
In your case, you can use two UILabels, on the left for percentages, on the right for the rest. Or choose a monospaced font.
First, additional questions:
1) Under what version of the OS is development underway? 7+?
2) Are you creating the UILabel from code or on the Storyboard?
I propose to start by looking at the UILabel property textAligment .
It is set by parameters from enum'a - NSTextAlignment
You need to either put it on the Storyboard, or write it in the code (for example, on viewDidLoad).
In the editor it looks like this:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question