iOS快速创建常用UI,使代码更加整洁并且提高开发效率
名称:CBUIKit
作用:快速创建常用的UI,使代码更加整洁并且提高开发效率~
作者:昶博
前言
作为一个iOS开发工程师,经常会写一些无聊的初始化方法,我觉得很浪费时间,所以就整理了一下,这个结合Masonry或者SDAutoLayout使用我觉得比较方便~
演示图
UILabel.png
UIView.png
UIButton.png
UIImageView.png
UITableView.png
UITextField.png
UITextView.png
初始化方法(这个不统一,你可以根据自己的习惯进行添加,这个是我平时使用的)
#pragma mark - For UILabel
+ (UILabel *)createLabelWithTextColor:(UIColor *)textColor
fontSize:(CGFloat)fontSize;
#pragma mark - For UIView
+ (UIView *)createViewWithBgColor:(UIColor *)bgColor;
+ (UIView *)createViewWithBgColor:(UIColor *)bgColor
cornerRadius:(CGFloat)cornerRadius;
#pragma mark - For UIButton
+ (UIButton *)createButtonWithTitle:(NSString *)title
fontSize:(CGFloat)fontSize
titleColor:(UIColor *)titleColor;
+ (UIButton *)createButtonWithTitle:(NSString *)title
fontSize:(CGFloat)fontSize
titleColor:(UIColor *)titleColor
cornerRadius:(CGFloat)cornerRadius;
#pragma mark - For UIImageView
+ (UIImageView *)createImageView;
+ (UIImageView *)createImageViewWithCornerRadius:(CGFloat)cornerRadius;
#pragma mark - For UITableView
+ (UITableView *)createTableViewWithStyle:(UITableViewStyle)style
separatorStyle:(CGFloat)separatorStyle;
#pragma mark - For UITextField
+ (UITextField *)createTextFieldWithPlaceholder:(NSString *)placeholder
textColor:(UIColor *)textColor;
#pragma mark - For UITextView
+ (UITextView *)createTextViewWithTextColor:(UIColor *)textColor
fontSize:(CGFloat)fontSize;
Demo地址
慢慢的在整理项目中的一些基础代码,优化写法,算是一个小总结吧~
- 如何挑选出优质基金,实现财富快速增值?
- 4个信号说明你的血液“粘稠如浆糊”!饭后一口它快速清血管
- 【庆安县华夏童年雅典贝贝早教幼儿园】 鸡蛋里加点这个,快速止
- 睡前3分钟,按按6个穴位,湿疹、荨麻疹快速止痒!不好天理难容
- 近 8 万首手写诗词,都藏在这个古风 App 里 - 郢雪 #iOS
- iPhone X/8去升级:iOS 11新更新修复摄像头大Bug
- 高血压再馋也别吃它,贪吃一点血压快速升高
- 八周,教你一步步练出马甲线!
- 如何快速给4-6个月宝宝制作营养价值高的辅食?
- 货车驶入快速内环禁行区 将被电子警察抓拍