定义类别
#import <UIKit/UIKit.h>
@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];