UI控件笔记(十六):UI之Uibutton,UIview,UIlbel等初始化的封装
来源:互联网 发布:actionscript 3 源码 编辑:程序博客网 时间:2024/05/18 03:46
一、MyUIClass.h
#import <Foundation/Foundation.h>
@interface MyUIClass : NSObject
+(UIView *)makeUIViewWithFram:(CGRect)rect andBackColor:(UIColor*)color;
+(UILabel *)makeUILabelWithFrame:(CGRect)rect andBackColor:(UIColor*)backColor andText:(NSString *)text andTextColor:(UIColor *)textColor andFont:(UIFont *)font andAlignment:(NSTextAlignment)alignment;
+(UIImageView *)makeUIImageViewWithFrame:(CGRect)rect andImage:(NSString *)imageName;
+(UITextField *)makeUITextFieldWithFrame:(CGRect)rect andDelegate:(id)target andBorderStyle:(UITextBorderStyle)borderStyle andPlaceholder:(NSString *)str andAutocorrectionType:(UITextAutocorrectionType)autocorrectionType andAutocapitalizationType:(UITextAutocapitalizationType)autocapitalizationType andClearButtonMode:(UITextFieldViewMode)clearButtonMode andSecureTextEntry:(BOOL)secureTextEntry andKeyboardType:(UIKeyboardType)keyboardType andReturnKeyType:(UIReturnKeyType)returnKeyType;
+(UIButton *)makeUIButtonWithFrame:(CGRect)rect andType:(UIButtonType)type andTitle:(NSString *)title andImageName:(NSString *)iamgeName andTarget:(id)target andSelector:(SEL)selector andEvent:(UIControlEvents)event andState:(UIControlState)state;
@end
二、MyUIClass.m
#import "MyUIClass.h"
@implementation MyUIClass
+(UIView *)makeUIViewWithFram:(CGRect)rect andBackColor:(UIColor *)color
{
UIView *view = [[UIView alloc] initWithFrame:rect];
view.backgroundColor = color;
return [view autorelease];
}
+(UILabel *)makeUILabelWithFrame:(CGRect)rect andBackColor:(UIColor *)backColor andText:(NSString *)text andTextColor:(UIColor *)textColor andFont:(UIFont *)font andAlignment:(NSTextAlignment)alignment
{
UILabel *lab = [[UILabel alloc] initWithFrame:rect];
lab.text = text;
lab.backgroundColor = backColor;
lab.textColor = textColor;
lab.font = font;
lab.textAlignment = alignment;
return [lab autorelease];
}
+(UIImageView *)makeUIImageViewWithFrame:(CGRect)rect andImage:(NSString *)imageName
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:rect];
imageView.image = [UIImage imageNamed:imageName];
return [imageView autorelease];
}
+(UITextField *)makeUITextFieldWithFrame:(CGRect)rect andDelegate:(id)target andBorderStyle:(UITextBorderStyle)borderStyle andPlaceholder:(NSString *)str andAutocorrectionType:(UITextAutocorrectionType)autocorrectionType andAutocapitalizationType:(UITextAutocapitalizationType)autocapitalizationType andClearButtonMode:(UITextFieldViewMode)clearButtonMode andSecureTextEntry:(BOOL)secureTextEntry andKeyboardType:(UIKeyboardType)keyboardType andReturnKeyType:(UIReturnKeyType)returnKeyType
{
UITextField *textField = [[UITextField alloc] initWithFrame:rect];
textField.delegate = target;
textField.borderStyle = borderStyle;
textField.placeholder = str;
textField.autocorrectionType =autocorrectionType;
textField.autocapitalizationType = autocapitalizationType;
textField.clearButtonMode = clearButtonMode;
textField.secureTextEntry = secureTextEntry;
textField.keyboardType = keyboardType;
textField.returnKeyType = returnKeyType;
return [textField autorelease];
}
+(UIButton *)makeUIButtonWithFrame:(CGRect)rect andType:(UIButtonType)type andTitle:(NSString *)title andImageName:(NSString *)iamgeName andTarget:(id)target andSelector:(SEL)selector andEvent:(UIControlEvents)event andState:(UIControlState)state
{
UIButton *btn = [UIButton buttonWithType:type];
btn.frame = rect;
if (type ==0) {
[btn setImage:[UIImage imageNamed:iamgeName] forState:state];
}else{
[btn setTitle:title forState:state];
}
[btn addTarget:target action:selector forControlEvents:event];
return btn;
}
@end
- UI控件笔记(十六):UI之Uibutton,UIview,UIlbel等初始化的封装
- UI控件笔记(六):UI之UINavigationController、navigationBar和UIView的封装
- UI控件笔记(三):UI之UIButton的属性
- UI控件笔记(一):UI之UIView的属性
- UI控件之UIButton
- 给UIView 的子类们 UIButton UILbel等 。。。。加一个虚线圆角的border
- UI笔记之UIButton
- UI控件笔记(十四):UI之自定义导航条的封装
- UI控件笔记(十五):UI之自定义搜索框的封装
- UI控件之UIButton详解
- iOS UI控件之----UIButton
- UI控件笔记(四):UI之UITextField的属性
- iOS基础——UI控件之UIView、UITextField、UILabel、UIColor、UIButton、UIImageView
- IOS入门学习笔记(普通UI控件--UIButton)
- iOS-UI-基本控件之UIButton
- iOS UI基础控件之UIButton
- IOS UI控件 - UIButton
- UI控件--UIButton
- Linux服务器Cache占用过多内存导致系统内存不足问题的排查解决
- HLOI2016滚粗记
- 多线程编程之线程的封装
- Tortoise SVN 加载路径中包含中文字符
- 一点小问题
- UI控件笔记(十六):UI之Uibutton,UIview,UIlbel等初始化的封装
- CodeIgniter3.0+Nginx的伪静态配置
- 关于<< 和>>操作
- java学习笔记5.17
- 40亿数据Map插入
- uva 1388
- hive中的lateral view 用法详解上篇
- linux chmod命令
- The real prerequisite for machine learning isn’t math, it’s data analysis