priore

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

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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×