iOS 设置button左文字右图片

定义类别

#import 

@interface UIButton (CustomMethods)

- (void)rolloverImageTextLocation;

@end
#import "UIButton+CustomMethods.h"

@implementation UIButton (CustomMethods)


- (void)rolloverImageTextLocation {
    
    [self setTitleEdgeInsets:UIEdgeInsetsMake(0, -self.imageView.image.size.width, 0, self.imageView.image.size.width)];
    
    [self setImageEdgeInsets:UIEdgeInsetsMake(0, self.titleLabel.bounds.size.width , 0, -self.titleLabel.bounds.size.width)];
    
}

 

使用
[_rateButton rolloverImageTextLocation];

你可能感兴趣的:(按钮(Button))