Objective-C Tips & Trick - Prioregroup.com
[Objective-C] How to put an image and a bottom text together in a UIButton
       
back

@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






Copyright © 1996-2018 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.
prioregroup.com