Skip to content

Instantly share code, notes, and snippets.

@priore
Created October 25, 2013 23:39
Show Gist options
  • Save priore/7163478 to your computer and use it in GitHub Desktop.
Save priore/7163478 to your computer and use it in GitHub Desktop.
How to put an image and a bottom text together in a UIButton
@implementation UIButton (Style)
const CGFloat kImageTopOffset = -15;
//const CGFloat kTextBottomOffset = -30;
- (void)centerButtonImageTopAndTextBottomWithOffset:(CGFloat)bottomOffset
{
[self setTitleEdgeInsets:UIEdgeInsetsMake(0.0, -self.imageView.image.size.width, -bottomOffset, 0.0)];
[self setImageEdgeInsets:UIEdgeInsetsMake(kImageTopOffset, 0.0, 0.0, -self.titleLabel.bounds.size.width)];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment