Fluid full screen view transitions on iOS - ios

I have a simple app that has a set of coloured views, one red, one green and one blue.
I am trying to make it so that when a swipe gesture is made the current view will switch to the next one in the list in a fluid manner, it looks like moving a long piece of paper with different colours on it.
Is there a way to do this (CoreAnimation)?

You could first look into UIScrollView. It seems to me that what you are trying to accomplish is the same you have, say, in Mobile Safari on an iPhone, when you show all your current pages and can go from one to the next by scrolling. This tutorial is particularly close to what you describe.
If you are looking into more advanced kind of transformations, than Core Animation would be the option.
Actually, nothing prevents using both approaches, UIScrollView to handle the swipe, Core Animation to add more animation to the pack...

You could use a UIScrollView to accomplish this. Add all of your colored views as subviews to the scroll view. Make sure your contentSize is setup appropriately and optionally setup paging to make the scrolling always snap to a certain border. See the scroll view programming guide for more info Scroll View Programming Guide

Related

Swift: Zooming image with scrollView like Facebook

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.
What I want to achieve after that is to also be able to pinch/double tap to zoom. Like this:
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!

How to correctly animate change of size of a paged UICollectionView

I have an iPad app similar to the iPad Keynote with a narrow overview on the left and a paged UICollectionView of my "slides" on the right. The collection view is using the default FlowLayout. Some of these slides are standard PDFs and some are embedded UIViewControllers that have been scaled (with a CGAffineTransform) and embedded in the cell. I'd like to smoothly animate the overview sidebar offscreen and zoom the current page cell to fullscreen. The collection view should allow paged swiping at whatever size. I'm using storyboards and autolayout.
I think I need to simultaneously animate about three things:
The collection view constraints (to the sidebar) to enlarge/shrink it
The flow layout's sizeForItemAt: value
The CGAffineTransform on the embedded view controller.
I have some pieces working (a single embedded View Controller "slide" that scales correctly) but cannot get the collectionView/cell resize dance to work correctly. The cell resize animation is jerky, or ends up with the wrong offset, or works for the leftmost cell but not for other cells.
I've tried most of the suggestions in the answers to this question but with no convincing success. I can't believe it's impossible but at this point I'm considering the smoke and mirrors approach of animating a static slide and hiding it after the animation completes. The attached video - ignoring the glitches - illustrates the kind of effect I'm after:
It's worth noting, on close inspection, that Keynote cheats somewhat when it comes to swiping between slides in edit mode, and manually manages the next slide sliding onscreen, so probably doesn't use a UICollectionView.
Has anyone done anything similar, or have any suggestions for things to try?
I managed to solve this. There's a proof-of-concept GitHub repo here.
There are a few moving parts:
There are two pieces of UIView scaling code. I suspect these could be combined with suitable delegate references as the nested view controllers are embedded. The first piece scales (statically) correctly when the Collection View cell is created. The second is an animated scale/translate when the sidebar size is changed.
I added a FlowLayout subclass to remove flicker as the collection's layout is invalidated during scaling.
The sidebar-related transform in the top-level VC uses most of the tricks in the book - invalidateLayout(), performBatchUpdates(...), layoutIfNeeded() etc. as well as animating the contentOffset to the correct value. Some manual tracking of the correct page/slide is required.
There's still a slight flicker occasionally at the start of resizing. This may not be an issue with my particular colour-scheme which will be black on dark gray. Bonus points if anyone can suggest how to track this down or alleviate it.

iOS Swift: Expandable/Collapsable View that contains a Horizontally Scrolling List

Im am relatively new to Swift/iOS and i have a quite complex task to Accomplish, and i want to know the best way for doing that.
I need to have a Custom View. This View displays some content, e.g. a news-article. If the user taps on the View, it expands and shows a more detailed version of the news article. Also, the user cann scroll horizontally (in the expanded or collapsed state) to get to the next article.
A Visual explanation
I searched for each problem individually. For scrolling, i found that i can use a scrollview with paging enabled, so that each swipe will lead to the next article. But im not sure if that is the best solution for my problem.
For expanding/Collapsing a view, i only have the idea to programmatically set the size of the view to fill the screen, so that auto layout would no longer display everything that is located beneath our custom view. Would that be possible? And is there any better solution?

How to pin an image/view inside a UIScrollView when scrolling

I've been searching for a way to pin views/images to the top of a UIScrollView when scrolling. However the posts/articles I came across are not in swift 3. I'm not sure if I'm typing my question in the web correctly. So my question is how can we achieve the same behavior as a UITableView or UICollectionView. When you scroll, a section will stick to the top until another section pushes it up. I'm wondering would we be able to use views/image and pin them at the top of the UIScrollView. Down below is a screenshot of a UIScrollView that has 4 views.
So when scrolling I would like to pin the first view/image to the top until another view/image pushes it. Also would it be possible to determine which view sticks to the top. So lets say I only want the red views to stick until another red view pushes it. Been looking for a way to achieve this type of behavior for a while now.
Please help, would really appreciate any help provided at this point. Thanks.
A few ways to do this, but you can use the scrollView delegate’s scrollViewDidScroll to capture the contentOffset and use a combination of the target view’s origin/center/transform properties to keep the view where you want it.
There’s a neat video explaining how to do this that Apple released during WWDC 2010, called something like “Advanced Scroll View Behavior”, if I remember correctly. It’s definitely worth a watch.

Make UIScrollView scroll from scrolling inside OR outside of it

Say I have a UIScrollView that scrolls horizontally just fine. It's height is around 50px. After usability testing, a lot of people are trying to scroll the contents by panning outside of it. Here is the setup:
Where it says "Amount" is the scrollview
I am wondering if it is possible to attach a UIPanGestureRecognizer on the blurred background it sits on top of and have it scroll along with that as well. If this is possible, could someone give me a start on what that approach would possibly look like?
Nah, the simple solution is simply make the scroll view bigger .. it's just that simple.
Have it mostly transparent, with your content sitting where you want it.
What you describe in your question is a good idea but it's extremely! hard to really implement well, a total pain. You simply "make the scroll view bigger".
Nice looking app.
These may be relevant to you...
The UICollectionView "swipe-away" in iOS7 app manager?
Show/hide UIToolbar, "match finger movement", precisely as in for example iOS7 Safari

Resources