// // UIButton+Common.h // XiaoYaoUser // // Created by 黄仪标 on 14/12/4. // Copyright (c) 2014年 xiaoyaor. All rights reserved. // #import <UIKit/UIKit.h> @interface UIButton (Common) /*! * 设置按钮正常状态下的图片 */ - (void)setNormalImageName:(NSString *)imageName; - (void)setNormalImage:(UIImage *)image; - (void)setNormalImageWithColor:(UIColor *)color; /*! * 设置按钮Hightlighted状态下的图片 */ - (void)setHightlightedImageName:(NSString *)imageName; - (void)setHightlightedImage:(UIImage *)image; - (void)setHightlightedImageWithColor:(UIColor *)color; /*! * 设置按钮Selected状态下的图片 */ - (void)setSelectedImageName:(NSString *)imageName; - (void)setSelectedImage:(UIImage *)image; - (void)setSelectedImageWithColor:(UIColor *)color; /*! * 设置按钮状态下的图片 */ - (void)setNormal:(UIColor *)color hightlighted:(UIColor *)hgColor; - (void)setNormal:(UIColor *)color selected:(UIColor *)selColor; - (void)setNormal:(UIColor *)color hightlighted:(UIColor *)hgColor selected:(UIColor *)selColor; @end
// // UIButton+Common.m // XiaoYaoUser // // Created by 黄仪标 on 14/12/4. // Copyright (c) 2014年 xiaoyaor. All rights reserved. // #import "UIButton+Common.h" #import "UIColor+ColorExtension.h" @implementation UIButton (Common) /*! * 设置按钮正常状态下的图片 */ - (void)setNormalImageName:(NSString *)imageName { [self setImage:kImageWithName(imageName) forState:UIControlStateNormal]; } - (void)setNormalImage:(UIImage *)image { [self setImage:image forState:UIControlStateNormal]; } - (void)setNormalImageWithColor:(UIColor *)color { [self setImage:[UIColor imageWithColor:color] forState:UIControlStateNormal]; } /*! * 设置按钮Hightlighted状态下的图片 */ - (void)setHightlightedImageName:(NSString *)imageName { [self setImage:kImageWithName(imageName) forState:UIControlStateHighlighted]; } - (void)setHightlightedImage:(UIImage *)image { [self setImage:image forState:UIControlStateHighlighted]; } - (void)setHightlightedImageWithColor:(UIColor *)color { [self setImage:[UIColor imageWithColor:color] forState:UIControlStateHighlighted]; } /*! * 设置按钮Selected状态下的图片 */ - (void)setSelectedImageName:(NSString *)imageName { [self setImage:kImageWithName(imageName) forState:UIControlStateSelected]; } - (void)setSelectedImage:(UIImage *)image { [self setImage:image forState:UIControlStateSelected]; } - (void)setSelectedImageWithColor:(UIColor *)color { [self setImage:[UIColor imageWithColor:color] forState:UIControlStateSelected]; } - (void)setNormal:(UIColor *)color hightlighted:(UIColor *)hgColor { [self setNormalImageWithColor:color]; [self setHightlightedImageWithColor:hgColor]; } - (void)setNormal:(UIColor *)color selected:(UIColor *)selColor { [self setNormalImageWithColor:color]; [self setSelectedImageWithColor:selColor]; } - (void)setNormal:(UIColor *)color hightlighted:(UIColor *)hgColor selected:(UIColor *)selColor { [self setNormal:color hightlighted:hgColor]; [self setSelectedImageWithColor:selColor]; } @end