创建UIButton
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的更多相关文章
- xcode UIButton创建、监听按钮点击、自定义按钮 、状态 、内边距
代码创建 //创建UIButton UIButton * btnType=[[UIButton alloc]init]; //设置UIControlStateNormal状态下的文字颜色 [btnTy ...
- 干货之UIButton的title和image自定义布局
当需要实现一个自定义布局图片和标题的按钮时候,不知道有多少少年直接布局了UIButton,亦或是自定义一个UIView,然后以空白UIButton.UILabel.UIImageVew作为subVie ...
- UI第二节——UIButton详解
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...
- iOS学习21之UILabel, UITextField, UIButton, UIImageView
1.UILabel 1> 概述 UILabel (标签): 是显示文本的控件.在App中 UILabel 是出现频率最高的控件 UILabel 是 UIView 子类,作为子类一般是为了扩充父类 ...
- UIButton的常用属性
可以通过代码的方式创建UIButton 通用实例化对象方法: UIButton *button = [[UIButton alloc] initWithFrame:rect]; 快速实例化对象方法: ...
- iOS支持图文混排的按钮(UIButton)
创建UIButton子类 直接上代码了 .h文件 创建UIButton子类 直接上代码了 .h文件 #import <UIKit/UIKit.h> @interface GraphicBt ...
- UILabel和UIButton
一.UILabel 1.UILabel:标签,主要用来显示文字. 创建步骤: (1)开辟空间并初始化(如果本类有初始化方法,使用自己的,否则,使用负父类的). UILabel *textLabel ...
- UIButton 详解
1)创建 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 风格有如下 typedef enum { UIButt ...
- ios中UIButton选中状态切换
关于UIButton的事件枚举有许多,平时用的少所以很多的都不是很清楚,今天了解了下,看了以前的代码,觉得在UIButton选中时操作写了许多冗余代码,而忽略了UIButton一个很重要的属性,如下: ...
随机推荐
- WebService--使用 CXF 开发 REST 服务
现在您已经学会了如何使用 CXF 开发基于 SOAP 的 Web 服务,也领略了 Spring + CXF 这个强大的组合,如果您错过了这精彩的一幕,请回头看看这篇吧: Web Service 那点事 ...
- JS时间操作
/** * 判断年份是否为润年 * * @param {Number} year */ function isLeapYear(year) { return (year % 400 == 0) || ...
- (转)iOS Wow体验 - 第二章 - iOS用户体验解析(2)
本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第二章译文精选的第二部分,其余章节将陆续放出.上一 ...
- java 版本SQLHelper
package com.jack.SQLHelper; import java.sql.*;import java.util.logging.*;import javax.swing.table.*; ...
- 【leetcode】Merge k Sorted Lists(按大小顺序连接k个链表)
题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity ...
- OCP-1Z0-051-题目解析-第28题
28. Which two statements are true regarding constraints? (Choose two.) A. A foreign key cannot cont ...
- DOS命令大全--具体解释
在Linux和Windows下都能够用nslookup命令来查询域名的解析结果 DOS命令大全一)MD--建立子文件夹 1.功能:创建新的子文件夹 2.类型:内部命令 3.格式:MD[盘符:][路径名 ...
- linux上网络配置不生效的怪异现象处理
1.在Linux上.在ifcfg-eth0上设置IP地址等信息 具体配置信息例如以下已 [root@rac01 Desktop]#more/etc/sysconfig/network-scripts/ ...
- 安装centos6.3
废话少说,今天安装镜像文件.版本为centos6.3 1.首先,我们已经创建了一个空的虚拟机,此时,打开虚拟机,选择的镜像文件,点击ok自己下载 2.点击绿色的三角箭头,你会看到下面页面.(如果报错T ...
- 操作系统下查看HBA卡信息wwn的方法
一.Windows 系统在Windows系统中,可以使用FC HBA卡厂家提供的管理软件查看光纤适配器的WWN号码,具体如下:Qlogic:SANsurferEmulex:HBAnyware http ...