Last active
August 29, 2015 14:24
-
-
Save marcolink/a0c55615d845697983bf to your computer and use it in GitHub Desktop.
UIButton with centered text and right aligned icon
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
UIImage *image = [UIImage new]; // your button icon image | |
self.button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter; | |
[self.button setImage:image forState:UIControlStateNormal]; | |
[self.button setImage:image forState:UIControlStateHighlighted]; | |
self.button.imageEdgeInsets = UIEdgeInsetsMake(0, self.button.frame.size.width - image.size.width, 0, 0); | |
self.button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, image.size.width); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment