Skip to content

Instantly share code, notes, and snippets.

@danhodos
Created May 29, 2012 21:00
Show Gist options
  • Save danhodos/2830677 to your computer and use it in GitHub Desktop.
Save danhodos/2830677 to your computer and use it in GitHub Desktop.
- (void)recalculateCartPrices {
ODCCart *currentCart = [ODCOrder currentOrder].cart;
NSNumberFormatter *formatter = [NSNumberFormatter new];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
self.cartShippingAndHandlingLabel.text = [formatter stringFromNumber:currentCart.shippingCost];
[self repositionLabel:self.cartShippingAndHandlingLabel];
self.cartSubtotalLabel.text = [formatter stringFromNumber:currentCart.subtotalCost];
[self repositionLabel:self.cartSubtotalLabel];
}
- (void)repositionLabel:(UILabel *)label {
CGRect beforeFrame = self.cartShippingAndHandlingLabel.frame;
[label sizeToFit];
CGRect afterFrame = label.frame;
afterFrame.origin.x = (beforeFrame.origin.x + beforeFrame.size.width) - afterFrame.size.width;
label.frame = afterFrame;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment