ios - ScrollView 内的表格 View : expand table view on scrolling and hide view above it

标签 ios swift uitableview uiscrollview

我想在向下滚动时隐藏表格 View 上方的 View ,并在向上滚动时再次显示它。许多应用程序都实现了这种行为。我怎样才能做到这一点?

最佳答案

Hook 表格上方 View 的高度约束

func scrollViewDidScroll(_ scrollView: UIScrollView) {

    let viewY = scrollview.contentOffset.y

    self.topViewH.constant = (viewY == 0) ? 200 : 0

    self.view.layoutIfNeeded()
}

关于ios - ScrollView 内的表格 View : expand table view on scrolling and hide view above it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50426272/

相关文章:

iOS:如何在不同(定义的)时间后顺序调用函数?

ios - swift 4.1 ISO8601DateFormatter 不解析 MRAID 广告内容传递的日期

ios - 使用 CKReference 与 CKRecord 的 CloudKit 性能

ios - 如何更新详细 View

ios - 向 UITableViewCell 添加了自动布局,但我看到了未知现象

swift - 带有阴影和角半径的分组 UITableView?

ios - 自定义 UIView 中的无效上下文 0x0 - 后续问题

ios - 如何在不打字的情况下检测 UITextField 光标移动?

ios - 无法在 AppDelegate 的 rootViewController 上显示 alertViewController

ios - 如何在一个 UIViewController 中维护两个 api?