UIButtonCreate.h

#import <UIKit/UIKit.h>

@interface UIButtonCreate : UIButton

/**
* 创建UIButton
*
* @param frame frame
* @param title title
* @param titleColor titleColor
* @param backgroundImage backgroundImage
* @param highlightedImage highlightedImage
* @param target target
* @param selector selector
*/
- (void)createButtonWithbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage Target:(id)target Selector:(SEL)selector; /**
* 创建UIButton
*
* @param frame frame
* @param title title
* @param titleColor titleColor
* @param backgroundImage backgroundImage
* @param highlightedImage highlightedImage
* @param image image
* @param target target
* @param selector selector
*/
- (void)createButtonWithImageAndbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage image:(UIImage *)image Target:(id)target Selector:(SEL)selector; /**
* 创建UIButton
*
* @param frame frame
* @param title title
* @param titleColor titleColor
* @param backgroundColor backgroundColor
* @param target target
* @param selector selector
*/
- (void)createNormalButton: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundColor:(UIColor *)backgroundColor Target:(id)target Selector:(SEL)selector; @end
/****************************************************/ UIButtonCreate.m
#import "UIButtonCreate.h" @implementation UIButtonCreate - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
} /*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/ - (void)createButtonWithbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage Target:(id)target Selector:(SEL)selector
{
[self setFrame:frame];
[self setTitle:title forState:UIControlStateNormal];
[self setTitleColor:titleColor forState:UIControlStateNormal];
[self setBackgroundImage:backgroundImage forState:UIControlStateNormal];
[self setBackgroundImage:highlightedImage forState:UIControlStateHighlighted];
[self setBackgroundColor:[UIColor clearColor]];
[self addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside]; } - (void)createButtonWithImageAndbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage image:(UIImage *)image Target:(id)target Selector:(SEL)selector
{
[self setFrame:frame];
[self setTitle:title forState:UIControlStateNormal];
[self setTitleColor:titleColor forState:UIControlStateNormal];
[self setBackgroundImage:backgroundImage forState:UIControlStateNormal];
[self setBackgroundImage:highlightedImage forState:UIControlStateHighlighted];
[self setImage:image forState:UIControlStateNormal];
[self setBackgroundColor:[UIColor clearColor]];
[self addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside]; } - (void)createNormalButton: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundColor:(UIColor *)backgroundColor Target:(id)target Selector:(SEL)selector
{
[self setFrame:frame];
[self setTitle:title forState:UIControlStateNormal];
[self setTitleColor:titleColor forState:UIControlStateNormal];
[self setBackgroundColor:backgroundColor];
[self addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside]; } @end

创建UIButton的更多相关文章

  1. xcode UIButton创建、监听按钮点击、自定义按钮 、状态 、内边距

    代码创建 //创建UIButton UIButton * btnType=[[UIButton alloc]init]; //设置UIControlStateNormal状态下的文字颜色 [btnTy ...

  2. 干货之UIButton的title和image自定义布局

    当需要实现一个自定义布局图片和标题的按钮时候,不知道有多少少年直接布局了UIButton,亦或是自定义一个UIView,然后以空白UIButton.UILabel.UIImageVew作为subVie ...

  3. UI第二节——UIButton详解

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...

  4. iOS学习21之UILabel, UITextField, UIButton, UIImageView

    1.UILabel 1> 概述 UILabel (标签): 是显示文本的控件.在App中 UILabel 是出现频率最高的控件 UILabel 是 UIView 子类,作为子类一般是为了扩充父类 ...

  5. UIButton的常用属性

    可以通过代码的方式创建UIButton 通用实例化对象方法: UIButton *button = [[UIButton alloc] initWithFrame:rect]; 快速实例化对象方法: ...

  6. iOS支持图文混排的按钮(UIButton)

    创建UIButton子类 直接上代码了 .h文件 创建UIButton子类 直接上代码了 .h文件 #import <UIKit/UIKit.h> @interface GraphicBt ...

  7. UILabel和UIButton

    一.UILabel 1.UILabel:标签,主要用来显示文字. 创建步骤: (1)开辟空间并初始化(如果本类有初始化方法,使用自己的,否则,使用负父类的).   UILabel *textLabel ...

  8. UIButton 详解

    1)创建 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 风格有如下 typedef enum { UIButt ...

  9. ios中UIButton选中状态切换

    关于UIButton的事件枚举有许多,平时用的少所以很多的都不是很清楚,今天了解了下,看了以前的代码,觉得在UIButton选中时操作写了许多冗余代码,而忽略了UIButton一个很重要的属性,如下: ...

随机推荐

  1. dom4j解析接口使用SOAP传递的xml

    xml 文件的格式类型: <?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope ...

  2. POJ 2392 Space Elevator 背包题解

    多重背包.本题不须要二分优化.相对简单点.由于反复数十分小,小于10. 而添加一个限制每种材料的高度做法.假设使用逆向填表,那么仅仅须要从这个高度往小递归填表就能够了. 还有就是注意要排序,以限制高度 ...

  3. Struts2 页面url请求怎样找action

    1.我们使用最原始的方法去查找action.不同注解. struts.xml文件先配置 <!-- 新闻信息action --> <action name="newsInfo ...

  4. Dynamics CRM 常用 JS 方法集合

    JS部分 拿到字段的值 var value= Xrm.Page.getAttribute("attributename").getValue(); Xrm.Page.getAttr ...

  5. XMLHttpRequest取得响应

    RresponseText:获得字符串形式的响应数据 responseXML:获得XML形式的响应数据 status和statusText:以数字和文本形式返回HTTP状态码 getAllRespon ...

  6. 树状jquery导航条

    $(function () {        $(".leftsecoundtitle").css({ "display": "none" ...

  7. css实现超连接按钮形式显示

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  8. C#拖动自己的定义标题栏(panel)以及实现窗体拖动关闭和最小化

    //没有标题 this.FormBorderStyle = FormBorderStyle.None; //任务栏不显示 this.ShowInTaskbar = false; //实现拖动 1.在窗 ...

  9. hadoop之MapReduce WordCount分析

    MapReduce的设计思想 主要的思想是分而治之(divide and conquer),分治算法. 将一个大的问题切分成很多小的问题,然后在集群中的各个节点上执行,这既是Map过程.在Map过程结 ...

  10. MFC线程(三):线程同步事件(event)与互斥(mutex)

    前面讲了临界区可以用来达到线程同步.而事件(event)与互斥(mutex)也同样可以做到. Win32 API中的线程事件 HANDLE hEvent = NULL; void MainTestFu ...