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.

1
  • Override scrollView delegate method and detect is user scrolled in that direction. Manually hide view according to scrolled distance. Commented Sep 9, 2015 at 7:49

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.