uicollectionview - 如何在 swift 4 ios 中像新闻行情一样平滑滚动 collectionViewCell
问题描述
我想像 swift 4 中的选框一样缓慢、平滑、自动地滚动 collectionView 单元格。
尝试用它制作动画并完美运行
func startScrolling(){
let co = collectionView.contentOffset.x
let no = co + 1
UIView.animate(withDuration: 0.001, delay: 0, options: .curveEaseInOut, animations: { [weak self]() -> Void in
self?.collectionView.contentOffset = CGPoint(x: no, y: 0)
}) { [weak self](finished) -> Void in
self?.startScrolling()
}
}
但从此无法获取索引,也无法点击,需要帮助
解决方案
推荐阅读
- pyspark - NameError:名称“dbutils”未定义
- terraform - 如何在 terraform 中创建地图
- rasa - 如何将 rasa 聊天机器人与 QA 平台(如用于团队的 stackoverflow)集成?
- python - 使用 python 和 Gmail API 从特定发件人的最后一封邮件中获取和解析数据
- javascript - 有没有办法使用 react-redux (useDispatch) 使用基于类的组件进行反应?我在渲染函数中使用 useDispatch
- html - 您如何设置视点元标记,以便我的 HTML 编写的网页在手机上以正确的比例显示?
- reactjs - 如何连接到它反应的 websocket 而不是普通的 javascript?
- javascript - 从 JSON 中划分 2 个变量的结果
- angular - 在 Angular-material 中显示图标的问题
- angular - TestBed.overrideProvider 现在覆盖提供者