// // UIButtom+formatter.m // jiaPei // // Created by apple on 15/11/16. // Copyright (c) 2015年 JCZ. All rights reserved. // #import "UIButton+formatter.h" @implementation UIButton(formatter) - (void) setImage:(UIImage *)image withTitle:(NSString *)title forState:(UIControlState)stateType { [self setImage:image withTitle:title Font:10 forState:stateType]; } - (void) setImage:(UIImage *)image withTitle:(NSString *)title Font:(CGFloat)font forState:(UIControlState)stateType{ [self.titleLabel setContentMode:UIViewContentModeCenter]; [self.titleLabel setBackgroundColor:[UIColor clearColor]]; [self setTitleColor:kTitleColor forState:stateType]; // [self setTitleColor:kTitleColor forState:stateType]; [self setTitle:title forState:stateType]; [self.titleLabel setFont:[UIFont scaleSize:font]]; [self setImage:image forState:stateType]; [self.imageView setContentMode:UIViewContentModeScaleAspectFit]; } -(void) setTitle:(NSString*)title textColor:(UIColor*)color Font:(CGFloat)font fotState:(UIControlState)stateType { [self setTitle:title forState:stateType]; [self setTitleColor:color forState:stateType]; [self.titleLabel setFont:[UIFont scaleSize:font]]; } - (void)setImage:(UIImage *)image withTitle:(NSString*)title textColor:(UIColor*)color Font:(CGFloat)font fotState:(UIControlState)stateType { [self.titleLabel setContentMode:UIViewContentModeCenter]; [self.titleLabel setBackgroundColor:[UIColor clearColor]]; [self setTitleColor:color forState:stateType]; [self setTitle:title forState:stateType]; [self.titleLabel setFont:[UIFont scaleSize:font]]; [self setImage:image forState:stateType]; [self.imageView setContentMode:UIViewContentModeScaleAspectFit]; } -(void)setTitleNormal:(NSString*)title { [self setTitle:title forState:UIControlStateNormal]; } -(void)setTitleSelect:(NSString*)title { [self setTitle:title forState:UIControlStateSelected]; } -(void)target:(id)obj { [self addTarget:obj action:NSSelectorFromString(@"btnClick:") forControlEvents:UIControlEventTouchUpInside]; } -(void)target:(id)obj tag:(NSInteger)tag { self.tag = tag; [self target:obj]; } @end