UITableView 可滚动到 UIVIewController

UITableView scrollable into UIVIewController

我有一个简单的 UIViewController,带有两个子视图,如下图所示

我想做的是当向下滚动 UITableView 内容时也将 UIView 推到顶部。

举例来说,我想用 Header 行为

复制 UITableView

是否可以使用 table header 进行白化?

在此先感谢您。

在我的脑海中,这是关于它应该如何工作的

override func scrollViewDidScroll(scrollView: UIScrollView) {
    let yPosition = scrollView.contentOffset.y
    if (yPosition > yourView.frame.size.height) {
        return;
    }
    yourView.frame = CGRectMake(0, -yPosition, yourView.frame.size.width, yourView.frame.size.height)
    tableView.frame = GRectMake(0, yourView.frame.origin.y + self.yourView.frame.size.height,  tableView.frame.size.width, tableView.frame.size.height)
}

你可能需要调整框架定位逻辑a,这是我的头顶。