swift-tableView滚动,里面图片发生偏移动画
来源:互联网 发布:感性和理性 知乎 编辑:程序博客网 时间:2024/06/04 17:47
- 在cell的content View上放一个UIView控件,设置cell高度与uiview的高度为300
- 在uiview上再添加一个UIImageView,设置左右靠边,高度设置为400
- 设置图片的填充模式为aspectFill【放张大图】
代码设置:
- 设置tableviewHeight = 300 2.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) // Configure the cell...// for cell in tableView.visibleCells { let coverView = cell.contentView.viewWithTag(100) let image = coverView?.viewWithTag(200) let rect = coverView?.convert((coverView?.bounds)!, to: nil) var y = UIScreen.main.bounds.size.height - (rect?.origin.y)! - 600 y *= 0.2 if y > 0 { y = 0 } if y < -100 { y = -100 } image?.frame.origin.y = y// } return cell }
- 3.
override func scrollViewDidScroll(_ scrollView: UIScrollView) { for cell in tableView.visibleCells { let coverView = cell.contentView.viewWithTag(100) let image = coverView?.viewWithTag(200) let rect = coverView?.convert((coverView?.bounds)!, to: nil) var y = UIScreen.main.bounds.size.height - (rect?.origin.y)! - 400 y *= 0.2 if y > 0 { y = 0 } if y < -100 { y = -100 } image?.frame.origin.y = y } }
动画效果如下:
0 0
- swift-tableView滚动,里面图片发生偏移动画
- swift tableview 滚动到指定行列
- IOS-TableView里面cell的显示动画
- swift之异步加载图片的tableview
- swift 里面tableview的cell代码创建方法
- iOS.swift 如何设置tableview禁止上下滚动
- Android 同时播放缩放动画和位移动画 时, 位移的路径会发生偏移.
- 鼠标滚动加载图片及图片动画
- TableView里面的cell根据图片或者文字自定义高度
- ios 广告图片无限滚动(swift)
- Swift 网络请求, 图片加载, tableView, collectionView, webView(八)
- IOS(swift)-scrollView(tableView) ·图片加载逻辑的优化
- swift 下拉放大tableView顶部图片 或 放大顶部地图
- tableView使用SDWebImage加载图片时滚动优化
- tableview 动画
- Tableview偏移的误差,偏移20,偏移64
- Swift开发教程--如何播放图片动画
- 简单图片上滚动轴动画效果
- 记录常用Linux 命令
- apache_httpd的安装与配置
- 算法训练 字符串的展开 时间限制:1.0s 内存限制:256.0MB
- hdu4411(#最小费用流)
- NumPy学习笔记(3)--排序与索引
- swift-tableView滚动,里面图片发生偏移动画
- java中StringBuilder的用法
- 基于linux操作系统下s5pv210板子的按键中断实验
- 从url中提取文件的扩展名
- Labview 边缘检测及模板匹配
- HBase知识总结
- js零碎知识(长期更新)
- MFC加载EXCEL代码
- java爬虫 爬取图书信息