1.tableview

    private lazy var cellId = "cellId"
fileprivate lazy var tv : UITableView = {
let tv = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
tv.register(UITableViewCell.self, forCellReuseIdentifier: cellId)
tv.translatesAutoresizingMaskIntoConstraints = false
tv.separatorStyle = .none
tv.backgroundColor = UIColor.white
tv.delegate = self
tv.dataSource = self
tv.bounces = false
return tv
}() // MARK: - UITableViewDelegate, UITableViewDataSource
extension JYJYRtbMineVc:UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
} func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) return cell
}
}

  

2.流水布局

    let JYLoadImageCollectionCellId = "JYLoadImageCollectionCell"
let JYAddImageCollectionCellId = "JYAddImageCollectionCell"
private lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
let itemWidth = CGFloat(Int((JY_DEVICE_WIDTH - 10 * 4)/3))
let itemHeight = itemWidth
layout.itemSize = CGSize(width: itemWidth, height: itemHeight)
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
layout.sectionInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10) let collectionV = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
collectionV.translatesAutoresizingMaskIntoConstraints = false
// collectionV.register(UINib.init(nibName: "JYChooseShopTimeCollectionCell", bundle: nil), forCellWithReuseIdentifier: "JYChooseShopTimeCollectionCell")
collectionV.register(JYLoadImageCollectionCell.classForCoder(), forCellWithReuseIdentifier: JYLoadImageCollectionCellId)
collectionV.register(JYAddImageCollectionCell.classForCoder(), forCellWithReuseIdentifier: JYAddImageCollectionCellId)
collectionV.delegate = self
collectionV.dataSource = self
collectionV.backgroundColor = .white
collectionV.showsHorizontalScrollIndicator = false
collectionV.showsVerticalScrollIndicator = false return collectionV
}() extension JYShopDetailFigureVc:UICollectionViewDataSource, UICollectionViewDelegate,UICollectionViewDelegateFlowLayout{
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
} func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
} func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: JYAddImageCollectionCellId, for: indexPath) as! JYAddImageCollectionCell
return cell
} func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
}
}

  

swift 快速创建一些基本控件的更多相关文章

  1. 用swift创建各种UI控件【iSwifting社区】

    为了方便大家学习,www.iSwifting.com社区为大家准备了创建各种UI控件的代码.開始看着语法可能有些别扭,当用习惯了,就认为还是非常不错的. 社区还添加了问答专区.有问题的朋友.虽然问.大 ...

  2. 【WPF学习】第六十五章 创建无外观控件

    用户控件的目标是提供增补控件模板的设计表面,提供一种定义控件的快速方法,代价是失去了将来的灵活性.如果喜欢用户控件的功能,但需要修改使其可视化外观,使用这种方法就有问题了.例如,设想希望使用相同的颜色 ...

  3. 使用前端开发工具包WijmoJS - 创建自定义DropDownTree控件(包含源代码)

    概述 最近,有客户向我们请求开发一个前端下拉控件,需求是显示了一个列表,其中包含可由用户单独选择的项目控件,该控件将在下拉列表中显示多选TreeView(树形图). 如今WijmoJS已经实现了该控件 ...

  4. 创建 WPF 工具箱控件

    创建 WPF 工具箱控件 WPF (Windows Presentation Framework) 工具箱控件模板允许您创建 WPF 控件,会自动添加到 工具箱 安装扩展的安装. 本主题演示如何使用模 ...

  5. 通过WinForm控件创建的WPF控件无法输入的问题

    今天把写的一个WPF程序发布到别的机器上执行,发现一个比较奇怪的问题:在那个机器上用英文输入法无法输入数字,非要切换到中文输入法才行:但在我的机器上却是好好的. 最开始以为是输入法的问题,弄了好一阵子 ...

  6. android学习七(创建自己定义控件)

    前面学习的是android的基本控件和布局的使用,可是主要的控件和布局有时候并不能实现复杂的布局.我们来看下各种控件和布局的关系. 可见全部的控件都是直接或者间接的继承自View的,全部的布局都是直接 ...

  7. 关于如何在 Unity 的 UI 菜单中默认创建出的控件 Raycast Target 属性默认为 false

    关于如何在 Unity 的 UI 菜单中默认创建出的控件 Raycast Target 属性默认为 false 我们在 Unity 中通过 UI 菜单创建的各种控件,比如 Text, Image 等, ...

  8. React 创建自己定义控件

    React是Facebook的内部项目,当时facebook对自己市面上全部的javascript MVC都不惬意,于是就自己创建了一个新的框架.发现还挺好用.于是就开源了,这就是React. Rea ...

  9. IOS入门之创建视图和控件绑定

    学习IOS几天了,跟着教程做了两个小应用了,现在先来总结一下.今天就是创建视图和绑带到代码了.其实就是常见的MVC模式实现. 使用的Xcode版本是8.2. 在Xcode创建项目之后,默认就会创建一个 ...

随机推荐

  1. javascript的DOM操作获取元素

    一.document.getElementById()    根据Id获取元素节点 <div id="div1"> <p id="p1"> ...

  2. get return value of python in shell

    from: https://stackoverflow.com/questions/2115615/assigning-value-to-shell-variable-using-a-function ...

  3. Redis进阶实践之七Redis和Lua初步整合使用(转载 7)

    Redis进阶实践之七Redis和Lua初步整合使用 一.引言 Redis学了一段时间了,基本的东西都没问题了.从今天开始讲写一些redis和lua脚本的相关的东西,lua这个脚本是一个好东西,可以运 ...

  4. 【363】python 相关小技巧

    1. 对列表进行乱序 通过 random.shuffle() 方法实现,直接对列表进行操作 >>> import random >>> a = list(range ...

  5. 开发JSP自定义标签

    互联网上有很多种自定义标签,今天学的这种非常简单哟 1 编写一个普通类在类中定义一个经常使用得到的 函数 如public String toUpper(String str){ ...... } 2 ...

  6. 24.类的加载机制和反射.md

    目录 1类的加载连接和初始化 1.1类的加载过程 1.2类的加载器 1.2.1类的加载机制 1类的加载连接和初始化 1.1类的加载过程 类的加载过程简单为分为三步:加载->连接->初始化 ...

  7. Hibernnate 一对多多对一双向关联

    Group.java package com.bjsxt.hibernate; import java.util.HashSet; import java.util.Set; import javax ...

  8. Android代码规范

    Android代码规范——文章来源<IT蓝豹>http://itlanbao.com/preview.aspx#1,0 [-]一Import的次序二缩进Indentation总则示例代码规 ...

  9. webui-popover 一个轻量级的jquery弹出层插件

    该提示框插件可以和Bootstrap完美结合,但是并不一定需要和Bootstrap一起使用.它支持IE7以上的浏览器. 首先要引入需要的css  js  文件 <link rel="s ...

  10. centos 7.4安装教程

    1. 2. 3. 4. 5. 6. 7. 8.