iOS给UIButton的扩展

简介:
//
//  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


目录
相关文章
|
API iOS开发 Perl
iOS UIButton图文混排快捷显示
iOS UIButton图文混排快捷显示
iOS UIButton图文混排快捷显示
|
API iOS开发 Perl
iOS UIButton倒计时、指示器、粒子效果
iOS UIButton倒计时、指示器、粒子效果
iOS UIButton倒计时、指示器、粒子效果
|
iOS开发
iOS 之 自定义按钮UIButton
iOS 之 自定义按钮UIButton
322 0
iOS 之 自定义按钮UIButton
|
API iOS开发 Perl
ios UIButton点击快捷回调
ios UIButton点击快捷回调
|
iOS开发
iOS分享扩展支持自定义联系人
iOS可以通过添加Share Extension来扩展系统的分享组件,能够支持将网页,图片,音乐或任何接入了系统分享组件功能的应用分享到我们自己的App内。
349 0
|
搜索推荐 iOS开发
iOS小技能:消息推送扩展的使用
iOS小技能:消息推送扩展的使用
559 0
iOS小技能:消息推送扩展的使用
|
网络协议 Unix API
iOS进程间的实时通讯方案: local socket(解决扩展和容器应用的实时通讯问题)
iOS进程间的实时通讯方案: local socket(解决扩展和容器应用的实时通讯问题)
400 0
iOS进程间的实时通讯方案: local socket(解决扩展和容器应用的实时通讯问题)
|
开发框架 开发工具 iOS开发
iOS开发封装一个可以响应超链接的label——基于RCLabel的交互扩展(二)
iOS开发封装一个可以响应超链接的label——基于RCLabel的交互扩展
249 0
iOS开发封装一个可以响应超链接的label——基于RCLabel的交互扩展(二)
iOS8新特性扩展(Extension)应用之四——自定义键盘控件
iOS8新特性扩展(Extension)应用之四——自定义键盘控件
500 0
iOS8新特性扩展(Extension)应用之四——自定义键盘控件