iOS: Create a custom graph with content that changes at runtime - ios

I'd like to create a graph with a lot of custom content and add information to this as the time elapses while the app runs.
The graph I have in mind will look similar to this:
The pink horizontal bar gets drawn as the time elapses.. as with the black value curve. The yellow vertical bar is linked to a specific event and I'd like to be able to draw more than one. Once the pink bar reaches the letter t then the first part of the graph will be overridden (<---- this is the direction of the overriding animation).
Any suggestion on how I can get this started? Any decent tutorial?
I'd like to do this in a custom UIView.
Any idea on which framework I should use in iOS? Is there a good tutorial for this?

I can advice to use CorePlot library.
It's flexible well-documented library that supports different kind of graphs.

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!

How to create a reversed Bottom Sheet from the top in iOS?

I need to implement a reversed bottom sheet which should be sliding from the top of the parent view to the bottom.I have done my research and found plenty of supported libraries, but all of them don't work with sliding from the top of the view. I have tried to apply translation and reverse a drawer layout by 180 degrees in Pulley, but it created issues with safe area in iPhoneX for example.
Perhaps I am overcomplicating things with manually editing libraries, but I would like to get possible solutions or sample codes for creating this particular UI.
It should be done with regular interface builder in code, not in Swift UI at the moment.
Perhaps the easiest way is create it manually?
It's not that hard to create a black overlay that animates in while having a rounded corners white view animating from the top?
I think editing existing libraries to make it work is more work than doing this yourself? :)
I can supply some code if you need it but perhaps try it yourself and come back with your code and I can help update it to make it work properly?

Pagination for line chart in iOS sdk?

I am using core plot to draw line chart which is showing weekly details of user.
Now what I want is, to swipe next week of graph like scroll view paging functionality (we can also see it on iPhone home screen)
Please refer below image for more details.
Please share any solution or any logic to implement above task.
You can implement this by placing your graph view inside UIScrollView and allowing horizontal scroll. You also may want to enable UIScrollView's pagination feature to achieve "iPhone home screen"-like effect that you're describing.
This part is pretty straightforward, but you may find this StackOverflow answer useful.
However, your performance may suffer if your graph doesn't have reasonable horizontal bounds — i.e if width of your graph is too big to render at one time. You need to test this specifically with your set of data.
If this is indeed the case, one solution is to create separate "reusable" graph views for each week (like reusable UITableViewCells) and render them on-the-fly when user scrolls to the left or to the right. In other words, only render current, next & previous weeks' graphs and update this each time the user flips the page.
P.S. This doesn't relate to your question directly, but you may also want to take a look at JBChartView by Jawbone. I prefer JBChartView over Core Plot because it's really well-written library for creating graphs that you can dig into and customise however you want (unlike from Core Plot which is basically "a black box").

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