Horizontal Scrolling with side content scaling on iOS - ios

I'm having problem solving how to get an effect like Duolingo's carousel scrolling of content. The effect is that the card in the middle would be the largest with ones on the sides some in and out as it
Has anyone done this or have an idea?

You can start by implementing some of the UIScrollViewDelegate methods. scrollViewDidScroll: will provide you with continuous events during the scroll and you should be able to calculate the scale of the buttons/images from this point.

Related

Proper way to imitate infinite view and animate it on iOS

I'm working on a control that looks like a wheel and is used for fast or precise scrolling of content. Here's an example from coach's eye app:
My first take looks like this:
Currently the vertical lines are implemented as set of UIViews. Sure enough these vertical line views could be easily replaced with image views to customise the look.
Each time user pans:
I modify frame.origin.x on all of the vertical line views
If some of the views go off screen - I remove them
If there's a gap on the left or on the right I create new views to fit the place
When user finishes the pan gesture, I start repeat NSTimer (with like 0.05 of a second) to animate decelerating of wheel movement. On each loop of timer in a nutshell:
Calculate distance to move lines and move them
Calculate velocity deceleration amount and adjust the velocity
A couple of questions:
Are there any iOS frameworks (e.g. CoreGraphics, CoreAnimation, UIKitDynamics) that are suited better for implementing these tasks than UIKit APIs I have used?
Can you suggest a better / more correct way to implement "infinite scrolling wheel" control ?
Can you suggest a better way to implement deceleration after user finishes panning the wheel?
Thanks
I had made my "infinite scrolling wheel" control by customizing SSRollingButtonScrollView. I think you should look at it once. I hope it will help you.
Apple already have a nice algorithm implemented for acceleration and deceleration - in UIScrollView. And you can use that, behind the scenes, to control other views / interaction. This is enabled by connecting the pan gesture from the scroll view to another view and acting as the delegate of the scroll view.
Check out the Enhancing User Experience with Scroll Views WWDC video for guidance.

Enlarging swipe angle in which a horizontal swipe is recognized in nested UITableView

I am trying to build a UI in iOS in which there is an outer paging UIScrollView inside of which are multiple UITableViews, each representing a page. The problem I am encountering is that the angle at which I must swipe to trigger the outer paging UIScrollView to scroll horizontally is too narrow. Here is a screenshot showing what I mean.
Essentially a user has to swipe at a near-perfect horizontal angle in order for the UITableView to ignore the gesture and pass it along to the outer UIScrollView, thereby triggering a horizontal page movement. This behavior quickly becomes annoying.
I have done extensive research on stack, to no avail. Some people suggest setting directionalLockEnabled, but that has no effect here (the inner UITableView has its direction locked, it's just too greedy with the angles it interprets as going in its direction). Others suggest modifications to the contentSize, but the contentSize of the views is, in point of fact, correct. Still others suggest using Gesture Recognizers, but those seem to have a delay before they kick in.
Can anyone suggest how to accomplish the behavior in the image above?

Horizontal Parallax Scrolling UIScrollView iOS

I'm trying to implement horizontal parallax on a paging scroll view which makes it so that one view appears to advance faster in the x direction but "lands" in the same spot (for example, say (0,0)). Here is my general setup / view hierarchy:
(transparent scroller, which intercepts / passes through scroll
events)
(object overlay that I want to move 1.2x pace in the x
direction, but doesn't surpass it's "landing spot")
(another overlay that I want to move at a 1.0x pace in the x
direction)
I know it has to do something with modifying the contentOffset and I have my delegates all setup so that they can all move at the 1x pace in the same direction...any hints as to the solution?
If you want to keep your current setup all you need to do is use the -(void)scrollViewDidScroll:(UIScrollView *)scroller delegate method with your scroller that is tracking the scroll events. In this method you will track the content offset and then use your speed multipliers to move your other views the way you want them to.
However you can easily do this with just 2 scrollviews, and when one moves you track its contentOffset in the same -(void)scrollViewDidScroll:(UIScrollView *)scroller delegate method and move the other accordingly.
Furthermore, if the two scrollviews are of different sizes, a natural parallax effect is incredibly easy to achieve tracking the contentOffset in the -(void)scrollViewDidScroll:(UIScrollView *)scroller delegate method and then using the value and the scrollview's contentSize to get a percentage of how far the scrollview moved and then simply set the contentOffset of the secondary scrollview to scroll that percentage of it's contentSize.
Let me know if you need further explanation.

Fast custom animation using CADisplayLink causes stroboscopic effect. How to avoid it?

Scenario:
Horizontally scrolling UIScrollView with reused page views (so that there are only few page viewcontrollers which are being reused similar way like UITableView cells). So that they are able to be updated with new content and reused I need to know exact position of UIScrollView's content view (offset). This works great.
Now I need to implement custom scrolling animation - I mean to programatically move the content view, so that user touches some buttons, and the scroll view scrolls to desired position with this custom animation. The movement can be very quick and very far. I can not use Core Animation for this, as I could not track position during animation (CA reports you only start and end of the movement). So I decided to use CADisplayLink, and calculate each UIScrollView content for each position. This works great too.
The only problem is, that sometimes I see stroboscopic effect - say I am moving the content to the right, and it looks like it is moving to left. If I look at builtin animation within UISCrollView using setContentOffset:animated:, the animation is smooth and nice. Does anyone know, how to get rid of this stroboscopic effect?
Most likely your issue is that timestamp is a double and you're assigning it to a float
Floats have 7 digits while Doubles have 15-16 digits.
So in other words you're experiencing data loss. By using double you should see a silky smooth animation.

How can I mimic inertial scrolling in a custom UIView when I can't use UIScrollView?

I need to implement an "infinite scrolling" timeline, where the pinch-to-zoom will change the scale of the timeline rather than zoom on the underlying view, almost exactly like the scroll view of the app iStreamer (see below). I don't think I can do this with UIScrollView and am considering implementing a custom UIView that draws the timeline and its contents.
Are there any classes/formulas/constants that can provide the physics simulation behind the "glass on liquid" effect of inertial scrolling?
iStreamer (above) has overlapping touchable elements and inertial scrolling. They might be doing this with a regular UIScrollView, but I don't know how to achieve the same effect. I need to add elements that could span very wide stretches (years or decades on a timeline).
Just use a UIScrollView, and don't allow zooming on the scrollview. Instead, add a pinch gesture recognizer which implements the desired behaviour for the pinch behaviour.
Use UIGestureRecognizer as jer suggested, otherwise this might help: http://macresearch.org/dynamics-scrolling

Resources