swift-tableView滚动,里面图片发生偏移动画
2017-02-19 16:37
344 查看
在cell的content View上放一个UIView控件,设置cell高度与uiview的高度为300
在uiview上再添加一个UIImageView,设置左右靠边,高度设置为400
设置图片的填充模式为aspectFill【放张大图】
代码设置:
设置tableviewHeight = 300
2.
3.
动画效果如下:
在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 } }
动画效果如下:
相关文章推荐
- 源码推荐(6.26):三级联想菜单(也可以当二级),tableView reloadData动画(swift)
- swift - tableView数据向上收缩动画
- swift 里面tableview的cell代码创建方法
- Swift - tableView单元格高度自适应(图片宽度固定,高度自适应)
- IOS-TableView里面cell的显示动画
- TableView里面的cell根据图片或者文字自定义高度
- iOS开发使用sdWebImage实现对tableView的cell加载图片淡入动画
- UI动画架构(上下滚动,里面View可以实现动画<透明,移动,缩放,变色>l)
- swift之异步加载图片的tableview
- iOS.swift 如何设置tableview禁止上下滚动
- Swift 网络请求, 图片加载, tableView, collectionView, webView(八)
- IOS(swift)-scrollView(tableView) ·图片加载逻辑的优化
- Ios精品源码,tableview下载视频直播源播放器图片位置3D立体旋转相册屏风动画
- Swift - 集成app启动页广告,切换rootViewController,支持LaunchImage和LaunchScreen.storyboard,支持GIF图片显示,支持视图过渡动画
- swift tableview的左滑删除,左滑显示自定义图片。
- webView、scrollView、TableView,为了防止滚动时出现偏移,底部黑框问题等
- swift开发笔记3 - 设置tableview背景图片
- 【学习笔记】tableview 简单用法,加图片,文字数组,锁定不滚动
- Ios精品源码,tableview下载视频直播源播放器图片位置3D立体旋转相册屏风动画
- IOS_实现tableview向上滚动全屏效果与点击展开动画