swiftswift3.0自己封装的快速构建页面的方法
//#param mark 控件
func creatLabel(frame:CGRect,text:String,textColor:UIColor,textFont:CGFloat,textAlignment:NSTextAlignment) -> UILabel {
let label = UILabel.init(frame: frame)
label.text = text
label.textColor = textColor
label.font = UIFont.systemFont(ofSize: textFont)
label.textAlignment = textAlignment
scorllView!.addSubview(label)
return label
}
func creatBtn(frame:CGRect,text:String,textColorNor:UIColor,textColorHig:UIColor,textFont:CGFloat,imageNor:String,imageHig:String,btnSet:Bool,target:Selector,textAlignment : NSTextAlignment,borderColor : UIColor) -> UIButton {
let btn = UIButton.init(frame: frame)
btn.setTitle(text, for: .normal)
btn.setTitleColor(textColorNor, for: .normal)
btn.setTitleColor(textColorHig, for: .selected)
btn.setTitleColor(textColorHig, for: .highlighted)
btn.setImage(UIImage.init(named: imageNor), for: .normal)
btn.setImage(UIImage.init(named: imageHig), for: .highlighted)
btn.setImage(UIImage.init(named: imageHig), for: .selected)
btn.isEnabled = btnSet
if IS_IPHONE_4_OR_LESS {
btn.titleEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 40)
btn.imageEdgeInsets = UIEdgeInsetsMake(5,UIScreen.main.bounds.width / 2 - 45, 5, -(UIScreen.main.bounds.width / 2 - 115))
}
if IS_IPHONE_5 || IS_IPHONE_SE{
btn.titleEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 40)
btn.imageEdgeInsets = UIEdgeInsetsMake(5,UIScreen.main.bounds.width / 2 - 45, 5, -(UIScreen.main.bounds.width / 2 - 115))
}
if IS_IPHONE_6 || IS_IPHONE_7{
btn.titleEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 40)
btn.imageEdgeInsets = UIEdgeInsetsMake(5,UIScreen.main.bounds.width / 2 - 55, 5, -(UIScreen.main.bounds.width / 2 - 130))
}
if IS_IPHONE_6P || IS_IPHONE_7P{
btn.titleEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 40)
btn.imageEdgeInsets = UIEdgeInsetsMake(5,UIScreen.main.bounds.width / 2 - 60, 5, -(UIScreen.main.bounds.width / 2 - 150))
}
btn.layer.masksToBounds = true
btn.layer.cornerRadius = 5
btn.layer.borderColor = borderColor.cgColor
btn.layer.borderWidth = 1
btn.titleLabel?.font = UIFont.systemFont(ofSize: textFont)
btn.titleLabel?.textAlignment = textAlignment
if btn.isEnabled == true {
btn.backgroundColor = UIColor.white
}else {
btn.backgroundColor = UIColor.white
}
btn.addTarget(self, action: target, for: .touchUpInside)
scorllView!.addSubview(btn)
return btn
}
func textfield(frame:CGRect,text:String,textFont:CGFloat,textColor:UIColor,textAlignment:NSTextAlignment,placeholder:String,borderStyle:UITextBorderStyle,borderColor : UIColor) -> UITextField {
let textfield = UITextField.init(frame: frame)
textfield.font = UIFont.systemFont(ofSize: textFont)
textfield.textColor = textColor
textfield.textAlignment = textAlignment
textfield.placeholder = placeholder
textfield.delegate = self
textfield.borderStyle = borderStyle
textfield.clearButtonMode = UITextFieldViewMode.whileEditing //叉号一直显示
textfield.adjustsFontSizeToFitWidth = true
textfield.backgroundColor = UIColor.white
textfield.keyboardType = UIKeyboardType.default
textfield.layer.masksToBounds = true
textfield.layer.cornerRadius = 5
textfield.layer.borderColor = borderColor.cgColor
textfield.layer.borderWidth = 1
scorllView!.addSubview(textfield)
return textfield
}
func textFieldView(frame:CGRect,text:String,textFont:CGFloat,textColor:UIColor,textAlignment:NSTextAlignment,placeholder:String,borderColor : UIColor) -> WTextVIew {
let textFieldView = WTextVIew.init(frame: frame)
textFieldView.font = UIFont.systemFont(ofSize: textFont)
textFieldView.textColor = textColor
textFieldView.textAlignment = textAlignment
textFieldView.delegate = self
textFieldView.text = text
textFieldView.layer.masksToBounds = true
textFieldView.layer.cornerRadius = 5
textFieldView.layer.borderWidth = 1
textFieldView.layer.borderColor = borderColor.cgColor
textFieldView.backgroundColor = UIColor.white
textFieldView.placeholder = placeholder
scorllView!.addSubview(textFieldView)
return textFieldView
}
swiftswift3.0自己封装的快速构建页面的方法相关推荐
- 快速构建页面APP程序员的人生计划
快速构建页面:bootstarp可视化工具 快速构建APP:APPCan工具 程序员人生计划参考:
- android动画封装,Android属性动画封装,快速构建动画
Android实现动画效果的方式主要有帧动画.补间动画.属性动画.关于安桌动画的基础知识可以查看这篇文章Android属性动画完全解析 这里我要讲的是如何快速构建出一个动画效果,如下图: 如果我们用属 ...
- 【spring authorization server系列教程】(一)入门系列,spring authorization server简介。快速构建一个授权服务器(基于最新版本0.3.0)
系列文章目录 [spring authorization server系列教程](一)入门系列,快速构建一个授权服务器 文章目录 系列文章目录 前言 一.目前已实现的功能 二.入门,一步一步快速开始构 ...
- C# Winform 通过FlowLayoutPanel及自定义的编辑控件,实现快速构建C/S版的编辑表单页面...
个人理解,开发应用程序的目的,不论是B/S或是C/S结构类型,无非就是实现可供用户进行查.增.改.删,其中查询用到最多,开发设计的场景也最为复杂,包括但不限于:表格记录查询.报表查询.导出文件查询等等 ...
- 从0到1,云服务助力全民直播快速构建大数据平台
随着业务的快速发展,全民直播如何应对来自技术与运营方面的挑战?6月7日,在上海世博中心,2018云栖大会·上海峰会阿里云支持与服务专场上,全民直播大数据架构师朱益发表主题演讲,详细介绍了从0到1,云服 ...
- 手把手教你快速构建一份全国疫情分布地图
本文基于百度地图API和fangkai提供的疫情数据API制作,是一份真实并实时的疫情场所分布地图,演示地址:https://rovertang.com/map/ncov/ 花絮 上次发表了如何制作一 ...
- 【一文到底】【0基础】【快速上手】Django基本使用
Django web开发 基础 1. Django的安装 和之前python一样,通过pip来安装即可 pip install django django和其他第三方Python模块一样,会在当前py ...
- 快速构建Spring Cloud工程
spring cloud简介 spring cloud为开发人员提供了快速构建分布式系统的一些工具,包括配置管理.服务发现.断路器.路由.微代理.事件总线.全局锁.决策竞选.分布式会话等等.它运行环境 ...
- 用Flutter + Dart快速构建一款绝美移动App
作者 | Wojciech Kuroczycki 译者 | 弯月 来源 | CSDN(ID:CSDNnews) 如今,与前端或移动相关的新框架层出不穷.所有从事Web开发的人都应该熟悉各种目不暇接的新 ...
最新文章
- [翻译]AKKA笔记 - CHILD ACTORS与ACTORPATH -6
- 用c语言完成银行排号系统,【分享】C语言 银行取票排队系统
- CCIE-LAB-第三篇-VRRP+SLA
- Struts2源码阅读(四)_DispatcherConfigurationProvider续
- tkinter要安装吗 苹果_建造存10万斤的苹果保鲜冷库安装工程要考虑哪些因素?...
- cuSPARSE库:(十四)求解稀疏三角形线性系统(solution of sparse triangular linear systems)
- python将一行作为字段_Python 变量代入,指定某一行截取输出字段
- 可用于神经网络的一些matlab函数
- linux硬链接符号,Linux — 硬链接与符号链接
- Scrapy入门操作
- ArrayList源码简单剖析 及与linkedlist vector 区别
- C盘文件分析(如何减小C盘容量)
- cad lisp 背景遮罩_AutoCAD心得体会
- 学计算机ppt感想60字,ppt制作的体会和感受
- 【MATLAB】MATLAB 可视化之曲面图与网格图
- 职教mooc计算机组装与维护课程网课答案,2020-网课答案-高职心理辅导与教育-中国大学mooc...
- 一加nfc门禁卡录入_一加7T手机如何开启NFC、复制门禁卡等功能
- QQ邮箱验证码登录(移动端邮箱验证登录)
- SIGIR20|LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation
- Android事件分发之ViewGroup篇 -- ViewGroup的dispatchTouchEvent、onTouchEvent、onInterceptTouchEvent之间关系
热门文章
- 64位win7安装vs2010出现“组件安装失败...”等问题的解决方法
- SSE4.1和SSE4.2 Intrinsics各函数介绍
- 【Qt】获取本地IP(IPv4)
- 虚拟机管理你的服务器,全面解析VMware的虚拟机管理解决方案
- 把本地mysql备份到服务器innodb_使用mysql备份工具innobackupex将本地数据 直接恢复 到远端服务器数据目录操作实例...
- Linux拷贝数据死机了,Linux系统“死机”时怎么办?
- 基于python的压测工具_Python Locust性能测试简介及框架实践
- share extension 不显示_你所不知道的网红小酒馆Helens
- Java项目:校园外卖点餐系统(java+SSM+JSP+maven+mysql)
- springboot中文文档_登顶 Github 的 Spring Boot 仓库!艿艿写的最肝系列