1 swi_crecell

    func numberOfSections(in tableView: UITableView) -> Int {return 1;}func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {return 5;}// cell高度func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {return 44;}// header 高度func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {return 0;}// footer 高度func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {return 0;}// cellfunc tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {var cell = tableView.cellForRow(at: indexPath);if (cell == nil) {cell = UITableViewCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: "cellID") ;}cell?.textLabel?.text = "123";return cell!;}// header viewfunc tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {return UIView.init();}// footer viewfunc tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {return UIView.init();}

2 代码体

swi_codebody

// MARK:0 设置UI// MARK:1 数据加载// MARK:2 事件响应// MARK:3 懒加载// MARK:4 方法抽取

3 创建一个按钮

            let btn = UIButton.init();btn.setTitle("", for: UIControl.State.normal);btn.setTitleColor(UIColor.black, for: UIControl.State.normal);btn.backgroundColor = UIColor.white;btn.titleLabel?.font = UIFont.systemFont(ofSize: 15);btn.addTarget(self, action: #selector(btnClick), for: UIControl.Event.touchUpInside);self.view.addSubview(btn)

4 创建CollectionView

    // sections countfunc numberOfSections(in collectionView: UICollectionView) -> Int {return 3;}// rows countfunc collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {return 5;}// itemSizefunc collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {return CGSize(width: 0, height: 0);}// header Sizefunc collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {return CGSize(width: 0, height: 0);}// footer Sizefunc collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {return CGSize(width: 0, height: 0);}// minimumLineSpacing 最小行间距func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {return 0;}// minimumInteritemSpacingfunc collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {return 0;}// insetForSectionfunc collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0);}// header 或者 footerfunc collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {if kind ==  UICollectionView.elementKindSectionHeader{let view = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "UICollectionReusableView", for: indexPath);view.frame = CGRect(x: 0, y: 0, width: self.collectionView.frame.width, height: 40);let lbl = UILabel.init(frame: CGRect(x: 10, y: 0, width: 150, height: 40));lbl.textColor = UIColor.init(red: 152/255, green: 152/255, blue: 152/255, alpha: 1);lbl.font = UIFont.systemFont(ofSize: 13);lbl.text = "输入你的标题";view.addSubview(lbl);return view;   }return UICollectionReusableView();}// collection Cellfunc collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "", for: indexPath) as! UICollectionViewCell;return cell;}// didselectedfunc collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {}

Swift Code Snippet相关推荐

  1. 使用 Code Snippet 简化 Coding

    在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...

  2. Xamarin.Forms XAML的辅助功能Code Snippet

    Xamarin.Forms XAML的辅助功能Code Snippet 在Visual Studio中,使用Code Snippet(代码片段)功能可以减少基础代码的编写量,如常见的标签.循环语句等. ...

  3. 如何创建 Code Snippet

    比如有一行自定义代码段: @property (nonatomic,copy) NSString *<#string#>; 需要添加到 Code Snippet 上,以帮助开发人员开发更便 ...

  4. CKEditor代码高亮显示插件Code Snippet安装及使用方法

    CKEditor网页编辑器 CKEditor 即 FCKEDITOR .FCKeditor是目前最优秀的可见即可得网页编辑器之一,它采用JavaScript编写.具备功能强大.配置容易.跨浏览器.支持 ...

  5. Visual Studio 的代码片段(Code Snippet)功能

    1.概述 在 Visual Studio 中,有一个快捷编辑代码的功能,比如当我们在 VS 编辑器(C#)中写出 关键字 foreach 后,敲击一下 Tab 键,VS 就帮我们自动补全:(插入代码段 ...

  6. iOS programming Code Snippet Library

    iOS programming  Code Snippet Library The freebie code comes from the code snippet library. 代码来自code ...

  7. wpf Route Event Code Snippet

    将下面内容保存为snippet后缀文件,通过vs的代码片段管理工具导入即可,快捷键请按需修改: <?xml version="1.0" encoding="utf- ...

  8. Objective C 常用代码片段制作(code snippet library)

    最近发现了一个比较好的东西,就是XCode提供的一个片段制作工具(code snippet library),主要作用就是可以省去我写一些经常使用的代码的麻烦 比如我经常使用的注释,实例化对象等的一些 ...

  9. anz的swift code_澳洲Commonwealth bank是不是只有一个SWIFT CODE?

    展开全部 不可能是一个的,因为swift code是用来定62616964757a686964616fe58685e5aeb931333433623131位具体是哪家银行哪家分行的.最保险的就是让亲戚 ...

最新文章

  1. 容器环境红队手法总结
  2. 前NASA工程师让钢琴开口说英文,还能自弹世界上最难曲目,快到冒烟
  3. “拖库”防不胜防,如何早做预防?
  4. CIO需“野蛮生长” 2017中国CIO高峰论坛7月开幕
  5. mysql核心数据库_从MySQL基础进军MySQL核心架构 178集MySQL数据库核心基础视频教程 MySQL基础案例教程...
  6. Android之Timer和TimerTask的介绍
  7. WPF应用程序内嵌网页
  8. .val()数据乱码_【目标检测数据集】PASCAL VOC制作
  9. Idea 创建简单的SpringBoot 父子项目
  10. 软件工程软件产品质量要求与评价_软件工程定义
  11. bzoj2463 [中山市选2009]谁能赢呢?
  12. vim搜索设置高亮:set hlsearch
  13. linux 触屏设备 无法处理touchevent_一次通讯干扰处理
  14. Linux虚拟文件系统之文件读取(sys_read())
  15. 在Application中集成Microsoft Translator服务之使用http获取服务
  16. 15、工作流Web流程设计器及表单设计器
  17. MSN天气不显示数据、打不开、微软商店打不开报错0x80131500
  18. UE4相机贴图,屏幕标注
  19. 姿态估计论文汇总 Stacked Hourglass/CPN/Simple Baselines/MSPN/HRNet
  20. 《C语言及程序设计》实践参考——定期存款利息计算器

热门文章

  1. centos7下安装docker(11容器操作总结)
  2. 求二维数组最大子数组
  3. SSL 1460——最小代价问题
  4. GridView的编辑,更新,取消,删除等功能演示
  5. mac 下周期调度命令或脚本
  6. 一段处理百分数的js代码
  7. MySQL 的“root”用户修改密码
  8. MFC-4简单的窗口重绘(非部分重绘)
  9. ASP.NET MVC 重点教程一周年版 第九回 HtmlHelper 【转】
  10. ASP.NET2.0 永恒密码之戒【月儿原创】