iOS快速创建常用UI,使代码更加整洁并且提高开发效率

2017 年 11 月 29 日 CocoaChina 昶博


  • 名称: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地址


慢慢的在整理项目中的一些基础代码,优化写法,算是一个小总结吧~


登录查看更多
0

相关内容

iOS 是苹果公司为其移动产品开发的操作系统。它主要给 iPhone、iPod touch、iPad 以及 Apple TV 使用。原本这个系统名为 iPhone OS,直到2010年6月7日 WWDC 大会上宣布改名为 iOS。
【2020新书】使用高级C# 提升你的编程技能,412页pdf
专知会员服务
60+阅读 · 2020年6月26日
【书籍推荐】简洁的Python编程(Clean Python),附274页pdf
专知会员服务
182+阅读 · 2020年1月1日
【书籍】深度学习框架:PyTorch入门与实践(附代码)
专知会员服务
167+阅读 · 2019年10月28日
强化学习最新教程,17页pdf
专知会员服务
181+阅读 · 2019年10月11日
《机器学习实战》代码(基于Python3)
专知
32+阅读 · 2019年10月14日
手把手教你用Python实现“坦克大战”,附详细代码!
机器学习算法与Python学习
12+阅读 · 2019年6月8日
Python机器学习课程(代码与教程)
专知
37+阅读 · 2019年5月13日
已删除
架构文摘
3+阅读 · 2019年4月17日
iOS自定义带动画效果的模态框
CocoaChina
7+阅读 · 2019年3月3日
请快点粘贴复制,这是一份好用的TensorFlow代码集
PyTorch 1.0尝鲜版,这些改进你需要注意
专知
4+阅读 · 2018年10月3日
一文读懂PyTorch张量基础(附代码)
数据派THU
6+阅读 · 2018年6月12日
Python 如何快速入门?
大数据技术
11+阅读 · 2018年4月9日
代码这样写不止于优雅(Python版)
数说工作室
4+阅读 · 2017年7月17日
Learning Implicit Fields for Generative Shape Modeling
Arxiv
10+阅读 · 2018年12月6日
Arxiv
3+阅读 · 2018年10月18日
Arxiv
8+阅读 · 2018年5月1日
Arxiv
10+阅读 · 2017年12月29日
VIP会员
相关VIP内容
相关资讯
《机器学习实战》代码(基于Python3)
专知
32+阅读 · 2019年10月14日
手把手教你用Python实现“坦克大战”,附详细代码!
机器学习算法与Python学习
12+阅读 · 2019年6月8日
Python机器学习课程(代码与教程)
专知
37+阅读 · 2019年5月13日
已删除
架构文摘
3+阅读 · 2019年4月17日
iOS自定义带动画效果的模态框
CocoaChina
7+阅读 · 2019年3月3日
请快点粘贴复制,这是一份好用的TensorFlow代码集
PyTorch 1.0尝鲜版,这些改进你需要注意
专知
4+阅读 · 2018年10月3日
一文读懂PyTorch张量基础(附代码)
数据派THU
6+阅读 · 2018年6月12日
Python 如何快速入门?
大数据技术
11+阅读 · 2018年4月9日
代码这样写不止于优雅(Python版)
数说工作室
4+阅读 · 2017年7月17日
Top
微信扫码咨询专知VIP会员