Created
May 29, 2012 21:00
-
-
Save danhodos/2830677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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