0

I am trying to build an iOS app that will have the structure of Facebook's feed:

A vertical collection view that will have cells. Each cell will consist of image and text.

In fact, I am building my app with the help of this video by LetsBuildThatApp (this guy rocks by the way).

Currently, I am able to touch the image and animate it to full width, and also pan to dismiss it if velocity on Y-axis is more than a specific threshold.

enter image description here

What I want to achieve after that is to also be able to pinch/double tap to zoom. Like this:

enter image description here

I searched around and found some great articles on how to use UISCrollView to zoom. [Article1, Article2].

The problem is that I use autolayout to perform animations but these articles either use Storyboards or frames to position the image in the center of the scroll view [or at least this is how I understand it]. And also they don't involve any animations to start with.

Also, I don't want to present or push a view controller onto the navigation controller stack. I would rather animate the view on top of the base view as I do now.

Any idea on how to achieve this?

Thank you in advance!

christostsang
  • 1,701
  • 3
  • 27
  • 46
  • What specific part are you having trouble with? At the end of the animation you show, is the image in a scroll view? You can use auto layout within that scroll view (tie the scrollView content frame to the image) Then, one way is to use the pan gesture to drive a height constraint on the image (width should be set to the aspect ratio of the height). – Lou Franco May 27 '19 at 20:36
  • No, at the end of the animation the image is just a replica of the initial image that is animated to a center position. If I set the scrollView content frame to the image, then if I try to zoom, it will zoom only inside the image frame. I want to zoom outside the image frame. Can you please elaborate on your last sentence? – christostsang May 27 '19 at 20:45
  • Hi, isn't this related to what you are doing? https://stackoverflow.com/questions/14433109/uiscrollview-zoom-does-not-work-with-autolayout I think the most upvoted answer should handle your scenario – Joshua Francis Roman May 28 '19 at 07:36
  • @JoshuaFrancisRoman I will check it now! It seems to be the root of all evil! :) If it works I will respond here as well. – christostsang May 28 '19 at 08:02
  • Tbf, I also have this scenario. Built using AutoLayout and trying to zoom using AutoLayout. In the end, on zoom I just mutated the frame. No issues though – Joshua Francis Roman May 28 '19 at 08:08
  • @JoshuaFrancisRoman So what you did was to replicate the starting image with an image of the same frame inside a scrollView (image should fill the superview [scrollView], then animate the scrollView to center by expanding width and height accordingly, and then when you performed zoom/double tap you expanded that frame? – christostsang May 28 '19 at 08:34

0 Answers0