iOS基本控件基于点语法实现,写法简单由你定义
来源:互联网 发布:java程序员接私活 编辑:程序博客网 时间:2024/05/17 02:52
新建一个UILabel分类(category),在.h中写入下面内容
/**
位置 ,居左,居中,居右
*/
-(UILabel *(^)(NSTextAlignment))LabelTextAlignment;
/**
背景颜色
*/
-(UILabel *(^)(UIColor *))LabelBackGroundColor;
/**
文字颜色
*/
-(UILabel *(^)(UIColor *))LabelTextColor;
/**
文字
*/
-(UILabel *(^)(NSString *))LabelText;
/**
字体大小
*/
-(UILabel *(^)(float))LabelFontSize;
/**
位置大小CGRect
*/
-(UILabel *(^)(CGRect))LabelRect;
/**
边框颜色
*/
-(UILabel *(^)(UIColor *))LabelBorderColor;
/**
边框大小
*/
-(UILabel *(^)(float))LabelBorderWidth;
/**
阴影颜色
*/
-(UILabel *(^)(UIColor *))LabelShadowColor;
/**
阴影偏移量
*/
-(UILabel *(^)(CGSize))LabelShadowOffset;
/**
label圆角
*/
-(UILabel *(^)(float))LabelCornerRadius;
/**
行数
*/
-(UILabel *(^)(int))LabelLines;
/**
添加到某个view上
*/
-(UILabel *(^)(UIView *))LabelSuperView;
//之后再.m中实现方法
/**
位置 ,居左,居中,居右
*/
-(UILabel *(^)(NSTextAlignment))LabelTextAlignment{
return ^(NSTextAlignment textAlignment){
self.textAlignment = textAlignment;
return self;
};
}
/**
背景颜色
*/
-(UILabel *(^)(UIColor *))LabelBackGroundColor{
return ^(UIColor *backGroundColor){
self.backgroundColor = backGroundColor;
return self;
};
}
/**
文字颜色
*/
-(UILabel *(^)(UIColor *))LabelTextColor{
return ^(UIColor *textColor){
self.textColor = textColor;
return self;
};
}
/**
文字
*/
-(UILabel *(^)(NSString *))LabelText{
return ^(NSString *text){
self.text = text;
return self;
};
}
/**
字体大小
*/
-(UILabel *(^)(float))LabelFontSize{
return ^(float fontSize){
self.font = [UIFont systemFontOfSize:fontSize];
return self;
};
}
/**
位置大小CGRect
*/
-(UILabel *(^)(CGRect))LabelRect{
return ^(CGRect frame){
self.frame = frame;
return self;
};
}
/**
边框颜色
*/
-(UILabel *(^)(UIColor *))LabelBorderColor{
return ^(UIColor *borderColor){
self.layer.borderColor = borderColor.CGColor;
return self;
};
}
/**
边框大小
*/
-(UILabel *(^)(float))LabelBorderWidth{
return ^(float borderWidth){
self.layer.borderWidth = borderWidth;
return self;
};
}
/**
阴影颜色
*/
-(UILabel *(^)(UIColor *))LabelShadowColor{
return ^(UIColor *shadowColor){
self.shadowColor = shadowColor;
return self;
};
}
/**
阴影偏移量
*/
-(UILabel *(^)(CGSize))LabelShadowOffset{
return ^(CGSize size){
self.shadowOffset = size;
return self;
};
}
/**
label圆角
*/
-(UILabel *(^)(float))LabelCornerRadius{
return ^(float cornerRadius){
self.layer.masksToBounds = YES;
self.layer.cornerRadius = cornerRadius;
return self;
};
}
/**
行数
*/
-(UILabel *(^)(int))LabelLines{
return ^(int lines){
self.numberOfLines = lines;
return self;
};
}
/**
添加到某个view上
*/
-(UILabel *(^)(UIView *))LabelSuperView{
return ^(UIView *view){
[view addSubview:self];
return self;
};
}
更多基础控件基于点语法实现,请到我的github上下载,地址:https://github.com/986138497/UIKit,如有问题请联系我的qq:986138497- iOS基本控件基于点语法实现,写法简单由你定义
- WPF窗体由小到大最基本的写法
- 正则表达式语法简单写法
- ios之点语法
- ios点语法
- ios之点语法
- IOS 点语法总结
- IOS点语法详解
- JSP基本语法与定义
- clojure-基本语法-函数定义
- clojure-基本语法-函数定义
- Android自定义控件 ----- 基本绘制流程,简单控件的实现
- ios基本语法
- IOS:Swift基本语法
- ios基本语法
- ios基本语法
- iOS UIWebView浏览器控件的简单实现
- iOS UIWebView浏览器控件的简单实现
- Heritrix开源爬虫配置1.14.4和3.1
- 把正整数n表示成若干个正整数的和,求积的最大值
- Rich featureHierarchies for accurate object detection and semantic segmentation 阅读笔记
- mysql 开启慢查询 清空slow_log日志或者slow_log表
- C/C++ 线程同步测试例子
- iOS基本控件基于点语法实现,写法简单由你定义
- 学习笔记之python入门
- 6.0动态申请权限问题
- ios 10 部分App无法连接网络或网络错误
- UNIX网络编程笔记二
- 前端web开发的MVC模式 - 从一个简单实例讲起
- Swift3.0中UIAlertView&UIAlertAction逐渐被抛弃,用UIAlertController代替
- windows 下使用nginx 实现负载均衡
- 解决provisional headers are shown的过程