What is the canonical way to animate views over a fixed background? - ios

In my two recent questions here and here I laid out my problem a bit, but I want to ask a more general question here. First my goal: I am trying to animate views side to side with a fixed background image.
I am new to iOS, and so I don't know all the tools that are available to me, but each time I started hacking this together I kept thinking that there must be a built-in way to do this. I didn't want to reinvent the wheel, so what is the common way to implement this?

The best approach I think is making a UIView based in two main views:
The background, that always will stay
And on top of it, another UIView with your animated view
In case you want to animate it, its quite easy, just check this:
iPhone UIView Animation Best Practice

Related

Swift Animation Similar to Line Chart

my question can be a little bit confusing, however I will do my best to explain it. So I need to create a view like below in the image, which looks like a line chart.
In other words, the line thumbs should be interactive, so that user can move them up and down, which will led to the movement of "ropes" between each pair. The problem is I can not figure out to start what kind of structure in swift so that I can create this view. So far, I am thinking about to create separate sliders and connect them by drawing, lines between them, but I think there should be some better solution. Any help, idea, advice or hint is appreciated. Thanks in advance.
Part 1. Learning to use "drawRect" in a UIView
Make a custom view, i.e. subclass UIView. To draw the nine angled line segments (and indeed the grid behind) you'll need to master core graphics. Fortunately there are many of QA on this very topic:
How to draw a line in the simplest way in swift
Part 2. Custom layers in UIView
You'll have to learn about adding custom CALayers to views. There are many examples of this, eg
https://stackoverflow.com/a/57465440/294884
https://stackoverflow.com/a/41553784/294884
(Note that for the small text labels, I would probably simply add many UILabels programmatically, which you will also need to learn about.)
Part 3. Using UISlider
There's really nothing wrong with using a UISlider for each of your red dots. If you're just getting started with iOS, I suggest trying that first to become familiar with it.
A handy tip is, simply use a horizontal stack view to hold them all - you can space them as you wish.
Part 4. Using gestures
Beyond UISlider. The red buttons would most likely be custom UIViews. And, most simply, you would use UIPanGestureRecognizer to detect the finger moving.
Again you can find many QA on this field of study, example Move UIView within parent view using pangesture
If you master these four general fields you will be able to achieve the view in question, good luck!

Which Controller is Used in App?

i am starting a new project based upon some Sketch design. It has following two designs: this and this so my question is how to accomplish this effect, which UIViewController is used here, is there some code example similar to this?
They are both most likely using either a UITableview or UICollectionView.
The cells are customised with what looks like a clear background and shadows all over the place.
They should be fairly straight forward to do. Just very unusual in that you'll have to set a clear background on the cell and add views for the data/images etc...

Creating a card based UI in iOS

Im trying to do app with a card based ui, kind of like Jelly. I was wondering the how this would be done. Im thinking by using a collection view but Im not sure. Are there any open source libraries that would make it easier to do this? Thanks.
You're probably not going to be able to accomplish this using out-of-the-box components. I don't think UICollectionView is going to get you very far. You will almost certainly need to roll your own.
I would start by creating a View Controller class for the "cards", instantiate a few of them, add the views as subviews to the main view, and get to the point where you can comfortably push these cards around with your fingers. You will want to read up on animating UIViews, and UIGestureRecognizers. Make sure the momentum is right. Apps like this really really demand highly-tuned physics, otherwise they'll feel awkward.
Once you get to the point where your cards are happily zipping around the screen, it's just a matter of getting them to "sink" into a couple pre-defined positions (focused front-and-center, and resting in a stack down below). You would probably also want to give your view controllers some sort of state that indicates whether they're "active", or not.
Easier said than done, obviously.

How to create multidirectional infinite/circular scrolling view like the HBO GO iPad App

My question is essentially what it says in the title--I would like to create a scrolling view similar to the one that appears under the 'Home' tab of the HBO GO iPad application.
I have looked into circular/infinite UIScrollViews, but they only discuss infinite content in one direction (either horizontal OR vertical) and bring up many problems when scroll speed gets too high. So my question is twofold:
A) Could they have created this scrolling view by subclassing UIScrollView? If so, please do let me know how?
B) If not, does anyone have ideas as to a starting point for how they could have created it? It runs very, very smoothly even at fast acceleration, and I'm trying to figure out how they created this.
Thanks in advance!
Reposting to get answer ;-)
The sample is named StreetScroller.
Referenced video is here.
I believe the successful technique will be to apply the techniques in the video in either a 2x2 or 3x3 grid and handle scrolling in both directions.
I have put together a library that provides an infinitely scrolling view in all directions. It allows you to very easily achieve the effect you’re looking for and much more. As the user scrolls around, the framework lays out the tiles and lets the delegate know so it can set up the tiles' presentations. This is indeed done by subclassing UIScrollView and as for performance, the framework introduces no lag: full 60 fps no matter how fast you scroll.
The framework with a sample app that displays Flickr images in an infinitely scrolling wall is here: https://github.com/vovagalchenko/scroll-for-days. Additionally, here's a video of the sample app in action: https://cloud.box.com/s/d6bgvlot175au5a3jeh5
I don't think there is an easy way to do it by sub classing UIScrollView
I have done something similar with a UIView and a custom gesture recognizer, moving views around nice they disappear off the side of the screen.
I hope this helps you.

2 UITableViewCells side by side without a custom background image?

I'm trying to make something like this in my iPhone app:
Is there an easy-ish way to do this without making background images and such? I'm following a "Drawing a Grid in a UITableView" guide found here: http://usxue.is-programmer.com/posts/14176.html but so far I can't get the rounded edges with borders like a normal grouped table view has.
Any ideas? Thanks!
After looking around and running into issues, I think my best bet is just to make two UIButton objects here. A LOT EASIER than what I was trying to do.

Resources