3

I have simple UIViewController with two subviews as shown on picture below

enter image description here

What i'm trying to do is when scroll down UITableView content to push out also UIView on top.

Let's say for example i want to replicate UITableView with Header behaviour

Is it possible whiteout using table header?

Thank you so much in advance.

Oleg Popov
  • 2,464
  • 1
  • 17
  • 15
  • Override `scrollView` delegate method and detect is user scrolled in that direction. Manually hide `view` according to scrolled distance. – Blind Ninja Sep 09 '15 at 07:49

1 Answers1

1

From the top of my head, this is about how it should work

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)
}

You might have to adjust the frame positioning logic a, this came from the top of my head.

MarkHim
  • 5,686
  • 5
  • 32
  • 64