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. HLS直播和时移项目上线

    兄弟姐妹们: 天翼视讯的高清HLS直播和时移项目上线,测试观看地址为:http://118.85.192.228/live/,同时支持移动终端和pc终端.移动终端支持ios client和androi ...

  2. 在Servlet中使用spring注入的bean

    package abu.csdn.servlet;    import java.io.IOException;    import javax.servlet.ServletContext;    ...

  3. VC++ CopyFile函数使用方法

    BOOL CopyFile( LPCTSTR lpExistingFileName, // pointer to name of an existing file LPCTSTR lpNewFileN ...

  4. 只包含schema的dll生成和引用方法

    工作中,所有的tools里有一个project是只包含若干个schema的工程,研究了一下,发现创建这种只包含schema的dll其实非常简单. 首先,在visual studio-new proje ...

  5. ASP.NET优化性能方法之一禁用调试模式(转)

    若要设置 ASP.NET 应用程序的调试模式,必须编辑应用程序的 Web.config 配置文件. 通常,ASP.NET 应用程序的 Web.config 文件与应用程序位于相同的 URL 位置上. ...

  6. app打包,发布(同步发生冲突)

    1:打包步骤: 1:桌面建立一个文件夹,名字叫keystore 2:点击build下面的 ,如下:     3:会出现如下界面: 4:下一步: 5:如果有keystore,请点击 choose exi ...

  7. 介绍 Visifire 常用属性的设置

    转载自http://www.cnblogs.com/xinyus/p/3422198.html 主要介绍 Visifire 常用属性的设置,用来生成不同样式的图例 设置Chart的属 //设置titl ...

  8. C/C++中的空类及抽象类大小

    代码: #include <iostream> using namespace std; struct A{ }; struct B{ int i; }; class C:B{ ; }; ...

  9. Arbitrage HDU

    Arbitrage                                              Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  10. line-height下的dispay:inline-block垂直居中

    html: <div class="search fl"> <span class="search-box"> <input ty ...