当前位置: 首页 > news >正文

iOS swift UICollectionView

文章目录

  • 1.纯代码自定义UICollectionViewCell
  • 2.禁止滑动(弹簧效果)
  • 3.UICollectionView的长按拖动
  • 2.在一个控制器中放两个UICollectionView或者UITableView,代理方法要怎么写

1.纯代码自定义UICollectionViewCell

import UIKitclass NewDeviceBottomCollectionViewCell: UICollectionViewCell {var model:NewBottomModel = NewBottomModel(image: "海拔", text: "test") {didSet{reloadData()}}override init(frame: CGRect) {super.init(frame: frame)setupUI()}required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}var bottomLabel = UILabel()var topImageView = UIImageView()func setupUI(){contentView.backgroundColor = newUIBlackcontentView.addSubview(topImageView)topImageView.snp.makeConstraints { make inmake.top.equalToSuperview().offset(10)make.width.height.equalTo(25)make.centerX.equalToSuperview()}contentView.addSubview(bottomLabel)bottomLabel.textColor = .whitebottomLabel.snp.makeConstraints { make inmake.centerX.equalToSuperview()make.top.equalTo(topImageView.snp_bottom).offset(10)}}func reloadData(){bottomLabel.text = "平均速度"topImageView.image = UIImage(named: model.image)}
}

参考博客:
Swift之自定义UICollectionViewCell - csdn

2.禁止滑动(弹簧效果)

        collectionView.bounces = false

参考博客:
iOS swift-UIScrollview,UITableview,UICollectionView单独禁止下拉(上拉)

3.UICollectionView的长按拖动

参考博客:
Swift下使用UICollectionView 实现长按拖拽功能

2.在一个控制器中放两个UICollectionView或者UITableView,代理方法要怎么写

http://www.lryc.cn/news/21627.html

相关文章:

  • 计算机三级数据库 填空题汇总
  • 【Java学习】初识Java
  • LabVIEW网络服务安全
  • 基于MaixBit(K210芯片)的图像识别猜拳手势博弈装置
  • leetcode 41~50 学习经历
  • SQL注入原理及漏洞利用(入门级)
  • 2023/2/26 Vue学习笔记 配置代理解决跨域[CORS ]的问题
  • 算法练习--深拷贝与浅拷贝
  • Wireshark “偷窥”浏览器与服务器三次握手
  • 基于stm32温湿度采集平台开发
  • 单机模拟kafka分布式集群(演示生产、消费数据过程)
  • 办公室人员离岗识别检测系统 yolov7
  • Android从屏幕刷新到View的绘制(一)之 Window、WindowManager和WindowManagerService之间的关系
  • #多源数据融合#:HSI与Lidar
  • android 权限控制与进程隔离
  • 链表(一):移除链表元素、设计链表等力扣经典链表题目
  • 计算机网络 第4章 作业1
  • Redis-Java代码使用示例
  • acwing3485最大异或和(trie树,贪心)
  • EasyRecovery16免费的电脑的数据恢复工具
  • 银行数字化转型导师坚鹏:平安银行数字化转型—橙E网战略研究
  • tun驱动之open
  • 计算机网络体系结构
  • 基础夯实,字节内部总结240道算法LeetCode刷题笔记,直呼太全
  • Three.js使用WebWorker进行八叉树碰撞检测
  • 【教程】Notion笔记多平台设置中文显示
  • [牛客Hot101]链表篇
  • Vue3 核心模块源码解析(上)
  • 【C进阶】指针的高级话题
  • 无源晶振匹配电容—计算方法