Created
September 16, 2013 12:11
-
-
Save Blankwonder/6579924 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
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; | |
CGFloat textWidth = [button.currentTitle sizeWithFont:button.titleLabel.font].width; | |
CGFloat imageWidth = button.currentImage.size.width; | |
CGFloat buttonWidth = button.frame.size.width; | |
CGFloat contentWidth = textWidth + 5 + imageWidth; | |
[button setTitleEdgeInsets:UIEdgeInsetsMake(0, - imageWidth + (buttonWidth - contentWidth) / 2.0f, 0, 0)]; | |
[button setImageEdgeInsets:UIEdgeInsetsMake(2, contentWidth / 2.0f + buttonWidth / 2.0f - imageWidth, 0, 0)]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment