如何从右侧对齐NSSting

时间:2018-08-24 12:20:23

标签: objective-c nsstring foundation

enter image description here>我已附上一张两张收据的图像。我要打印与右边的收据相同的东西。这就是我在最后做的事情。请提出建议。

 for ( items in _invoceNew.items)
{
    NSString *itemString = items.itemName;
    if ([itemString length] == 0)  {
        itemString = @"Item";
    }
    NSString *invoiceFormat = items.quantity;
    invoiceFormat = [invoiceFormat stringByAppendingString: items.amount];
    NSString *joinString = [NSString stringWithFormat:@"%-2s %-20s %1s\n",[items.quantity UTF8String], [itemString UTF8String] ,[items.amount.asLocaleCurrency UTF8String] ];
    const char *join = [joinString UTF8String];
    [_myPos POS_PrintText: join x:0 nWidthTimes:0 nHeightTimes:0 nFontType:0 nFontStyle:0];
}
  

金额应从右侧对齐。这样它就不会进入第二行。

0 个答案:

没有答案