Skip to content

Instantly share code, notes, and snippets.

@marcolink
Last active August 29, 2015 14:24
Show Gist options
  • Save marcolink/a0c55615d845697983bf to your computer and use it in GitHub Desktop.
Save marcolink/a0c55615d845697983bf to your computer and use it in GitHub Desktop.
UIButton with centered text and right aligned icon
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