In my application, I want to create a Receipt Layout for printing. I’m struggling to create proper alignment between strings.
I want to create something like this (with proper alignments)
Coke 2 comment1
Chocolate 3 comment2
ice 4 comment3
Currently I have done like this
NSMutableString* strBody = [NSMutableString string];
for (int i=0; i<[arrItems count];i++){
[strBody appendString:[NSString stringWithFormat:@"\n%@ %@ %@",[[arrItems objectAtIndex:i] objectForKey:@"ProductName"],[[arrItems objectAtIndex:i] objectForKey:@"ProductQuantity"],[[arrItems objectAtIndex:i] objectForKey:@"Comment"]]];
}
But, here I just use fixed length spaces, so the issue is I’m not getting proper alignment. Currently what I am struggling is how to put flexible spaces between string items?
If anyone had do something like this, please give me some help.
Thanks in advanced…
You can create separate
UILabeland usesetFrameproperty to align all the labels….or use
\t(tab character depending on length of the string….