0

I want to achieve this animation:

Here is the Gif: https://i.stack.imgur.com/vzr61.jpg

Since the content is dynamic, I'm using tableView to populate the data. I've tried scrollViewDidScroll delegate methods to change the constraints but it's not helping me. I've even tried swipe gesture, but still can't manage to achieve this.

Can anyone provide a knowledge, a bit of code for getting this animation.

Bhavuk Jain
  • 2,167
  • 1
  • 15
  • 23

1 Answers1

0

I have tried to tackle your issue in this project.

The flaw with this solution is that it requires an unattractive inset at the top of the table view to translate the offset into a meaningful variable with which to shrink the table view.

The relevant code in the project is within the scroll delegate function:

func scrollViewDidScroll(_ scrollView: UIScrollView) {
        let yOffset = min(0.0, max(-maximumOffset, scrollView.contentOffset.y))
        let constant = -yOffset
        topTableViewConstraint.constant = constant
        leadingTableViewConstraint.constant = constant / 5.0
        trailingTableViewConstraint.constant = constant / 5.0
        view.layoutIfNeeded()
    }

I am sorry that I cannot be more helpful, or provide you with a final solution.

Hopefully the project will aid you in find that answer.

Infinity James
  • 4,667
  • 5
  • 23
  • 36
  • Thanks!! This really helped me to get a start. Though I changed most of the code and finally, this is how it looks: https://www.dropbox.com/s/yx87vntqmfmemwc/scroll_table_shrink.mov?dl=0 Let me know if you would like to see the code, will create a pull request. – Bhavuk Jain Jun 24 '17 at 16:32
  • Yeah man, I'd love to see how you got it looking like that. Nice job – Infinity James Jun 24 '17 at 20:53
  • I've opened a pull request. Check it out! – Bhavuk Jain Jun 25 '17 at 08:25