123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- //
- // 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
|