如何使用动画获取iMessage滚动视图粘性快照?

时间:2017-10-17 16:52:42

标签: ios swift xcode animation autolayout

我已经解决了这个问题一段时间了,而且我没有看到任何关于如何在向上和向下滚动时创建平滑动画的好解决方案。我可以使用滚动视图代理来确定向上或向下滚动,但我不知道如何在Tableview扩展时实现MESSAGES和SEARCH BAR的平滑动画隐藏。我尝试使用堆栈视图使UITextfield和UILabel在向上滚动时隐藏,并在向下滚动时显示,并与tableview对齐。随着约束的更新,这创建了一个不稳定的tableview动作。

 func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
    self.lastContentOffset = scrollView.contentOffset.y
}
  func scrollViewDidScroll(_ scrollView: UIScrollView) {if (self.lastContentOffset < scrollView.contentOffset.y) {
        // moved to top
        UIView.animate(withDuration: 0.2, delay: 0.2, options: .curveEaseOut,
                       animations: {self.headerView.alpha = 1.0},
                       completion: { _ in  self.headerView.backgroundColor = UIColor.frostedGlass

是否有任何图书馆,或者有人能指出我在向上和向下滚动时如何实现顶视图和标签的平滑过渡所需的效果?

Scrolled Up

Scrolled down and hide search bar and Messages label

0 个答案:

没有答案