SHARE
TWEET

How to put an image and a bottom text together in a UIButton

priore Jul 2nd, 2013 528 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @implementation UIButton (Style)
  2.  
  3. const CGFloat kImageTopOffset   = -15;
  4. //const CGFloat kTextBottomOffset = -30;
  5.  
  6. - (void)centerButtonImageTopAndTextBottomWithOffset:(CGFloat)bottomOffset
  7. {
  8.     [self setTitleEdgeInsets:UIEdgeInsetsMake(0.0, -self.imageView.image.size.width, -bottomOffset, 0.0)];
  9.     [self setImageEdgeInsets:UIEdgeInsetsMake(kImageTopOffset, 0.0, 0.0, -self.titleLabel.bounds.size.width)];
  10. }
  11.  
  12. @end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top