ios - 嵌入 tableviewHeader 中的弹性 collectionView

标签 ios swift uitableview uicollectionview

在我的应用程序中,我有一个如下所示的屏幕:

enter image description here

我想为我的tableView实现一个可拉伸(stretch)的标题,它必须拉伸(stretch)嵌入在collectionView中的imageView,而collectionView又嵌入在tableViewHeader中。

我尝试在 tableView 中使用 UIScrollViewDelegate 但它完全有问题,因为我应该同时修改 collectionView + 单元格:

func scrollViewDidScroll(_ scrollView: UIScrollView) {

    let scrollY = scrollView.contentOffset.y

    if scrollY < 0 {
        var tmpFrame = tableViewHeader.frame
        tmpFrame.origin.y = scrollY
        tmpFrame.size.height = tableViewHeader.frame.height - scrollY
        tableViewHeader.frame = tmpFrame
    }
}

你知道如何实现这个功能或者有什么提示可以帮助我吗?谢谢。

最佳答案

如果您不必使用 UICollectionView,但您可以使用 UIPageViewUIScrollView 来完成此操作。

关于ios - 嵌入 tableviewHeader 中的弹性 collectionView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49560326/

相关文章:

ios - UITableView tableHeaderView 用户交互不起作用

ios - 从日期选择器保存当前时间以显示本地通知作为提醒

iphone - 无法在我的 xcode 应用程序中安装 Monkey Talk ios 代理

swift - 获取可选数组的计数作为字符串,或 nil

swift - 使用 Swift 在工具栏中切换播放/暂停 UIBarButtonItem

ios - 防止 UITableViewCells 在平移时突出显示

ios - 在 UITextView 上输入文本时动态扩展 UITableViewcell

ios - 如何从 Parse 中获取多个对象以保存在 Swift 中的 Local DataStorage 中?

swift - “bool”无法转换为 'uint8'

ios - 如何实现让 UITableView 设置其单元格的插图而不在整个表格上设置插图?