我有这个结构。滚动视图-> UICollectionview + 标签
此视图控制器具有项目数组(BlockItem)。在 scrollViewDidScroll 我更改当前测试标签(描述)
func scrollViewDidScroll(_ scrollView:UIScrollView)
{
let midX:CGFloat = scrollView.bounds.midX
let midY:CGFloat = scrollView.bounds.midY
let point:CGPoint = CGPoint(x:midX, y:midY)
guard
let indexPath:IndexPath = collectionView.indexPathForItem(at:point)
else
{
return
}
let currentPage:Int = indexPath.item
if let found = items.first(where: {$0.id == String(block[currentPage])}) {
description.text = found.description
}
}
当我移动我的 collectionview 单元格并从下一个单元格出现时,我想要我的描述标签的主要问题将是一起移动。换句话说,如果我向左滚动,我的描述应该与单元格一起移动,即向左移动并出现在屏幕的右侧。
我怎样才能做到这一点?我知道我可以制作一个大的collectionview,但我需要只有图像部分应该是可滚动的,而不是整个块。
这是我想要实现的目标
这是视频示例:仅当我在图像区域上滑动时滚动才有效,并且当我向下滚动页面时不起作用 https://drive.google.com/file/d/1kl1GYgXvK4bL3toTfOvpxF2WqS56pQO9/view?usp=sharing