priore

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

Jul 2nd, 2013
611
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