Recently we came across innovative UI controls like Path and Clear controls. I am pretty amazed to see a simple UITableView and its cells in iOS, can be tweaked to get a eye-catching effects as in Clear app. After that there came a series of controls using UITableView, but this one from raw engineering was quiet nice.
After playing with it, I revisited the nuances of UITableView and came up with this simple UI Layoout which is our topic now. Take at look at this demo
I laid down some rules before I started implementing.
1. I made clear that this control will not built ground up from scratch
2. Want to leverage the full power of Dequeue in UITableView
3. Above two rules, means I should be concentrating only on how the content is laid out to present the data in different manner to the user and make it fun.
The main task that revolves around this control is how do we lay out the table cells. I used some basic trigonometry function which find out the point in circumference of the circle.
So the heart of this control resides in this method where on the while we find out the YPosition of each cell and adding yOffset of the Scrollview’s content offset. This means that the cell would move relatively as the tableview is scrolled.
The goal is to find out the X Position which is obtained by using Circle / Ellipse Equation
Have modified the source code to support the inverse form of the circle i.e the circle can be turned toward right as shown in figure by setting the CIRCLE_RIGHT_DIRECTION macro to 1
Thanks Ramesh,
For landscape support, just you need to setup the auto-resizing masks correctly.. i guess the cell width is being hardcoded.. let me add this as issue and fix it.
Thanks. and to make it right, you need to add a couple of lines in setupShapeFormationInVisibleCells method
1. Add M_PI to the angle found after the line float angle = asinf(y/(radius)); i.e. angle = angle + M_PI
2. add 2 times HORIZONTAL_TRANSLATION to x i.e replace line x = x + HORIZONTAL_TRANSLATION; with x = x + HORIZONTAL_TRANSLATION * 2;
Step #1 would shift the angle to the left half of the circle.
Step #2 would shift the center to the other end of the screen i.e. towards right.
Yes, you are free to use this as long as it complies to MIT License. However, I appreciate a mention about my Name and a link to this blog in your App, but its *not mandatory*.
Also, If you are fine, I could add your App’s App Store link, under whatever title you provide, in my blog as well as in Github README file.
Hi, how would I implement this if I wanted a horizontal tableView ?? You know ? Like the way the sun is positioned on the sky throughout the day. I know about EasyTableView that has horizontal tableview scrolling.
Very cool. I was looking for a way to have a table scroll at an angle when I came upon your post. Excellent work.
To get my angled scrolling I suppose one could rotate items in the cells and offset them in some constant way (not unlike your ellipse method, except in a line which would be simpler). Not ideal.
I’ll keep looking but if anyone knows how to have a rotated table that scrolls at that angle, I would appreciate a poke.
This is a fantastic tutorial! What changes would need to be made to have this scroll around from the bottom of the screen? I’ve toyed with it a while, and it might be because I’m rusty on my math, but I can’t get it to work.
By bottom of the screen, I mean that the center point which all the objects rotate around would be located at the very bottom middle of the screen. Essentially what you have done from left & right side, but from the bottom! Thank you again!
Hi Bharath, I apologize for the late reply. I took the weekend off to clear my mind Your suggestion does work! Thank you so much! However, I have found myself stuck on other features of this in order to tailor it to how I need it to appear. If you don’t mind, I would like to email you with some more details on what I am trying to accomplish with your fantastic demo! I believe what I am needing should be pretty quick for you to figure out
RT @gregmaletic: First thought upon using an iPhone: this is a computer so easy my mom could use it. First thought using iOS 7: this will t… 3 hours ago
RT @anrickbregman: If you're doing, you're doing fine. Don't worry about the competition, it's not a race. Just make something beautiful, m… 1 day ago
Pingback: Open Source iOS Control For Quickly Creating A Beautiful Circular Scrollable List
Pingback: Open Source iOS Control For Quickly Creating A Beautiful Circular Scrollable List | WebScriptPlus.com
Nice and clean.
Great job.
Thanks Somesh
Awesome!!!
Thanks Kaushik.
Great. How easy is it to change the layout to Landscape and also compatible with iPad? What should be changed?
Thanks Ramesh,
For landscape support, just you need to setup the auto-resizing masks correctly.. i guess the cell width is being hardcoded.. let me add this as issue and fix it.
Rames,
You have to play with the Horizontal Ratio to find the correct xRadius and xRadius of the ellipse. Please check the latest source for the fix
Great job Bharath! I love it..
Thanks Chakri
Great post! how would I inverse it, and make it appear on right?
James,
Thanks. and to make it right, you need to add a couple of lines in setupShapeFormationInVisibleCells method
1. Add M_PI to the angle found after the line float angle = asinf(y/(radius)); i.e. angle = angle + M_PI
2. add 2 times HORIZONTAL_TRANSLATION to x i.e replace line x = x + HORIZONTAL_TRANSLATION; with x = x + HORIZONTAL_TRANSLATION * 2;
Step #1 would shift the angle to the left half of the circle.
Step #2 would shift the center to the other end of the screen i.e. towards right.
Check this CircleView Right
Hope this helps.
wow. thanks for the reply!! Really helpful!
How can I increase the circle radius (circle size) if I wish to have bigger circles on iPad? Thanks. Its a wonderful post.
You increase the Height and width of the tableview.
Amazing post and amazing blog! Keep up the great work Bharath! I’ve added your blog to my blog roll.
Thank you!
Hi Bharath,
Can I use this in my App for implementing some feature? Do I need to do anything with respect to licensing? Please advice.
Regards,
Ramesh.
Hi Ramesh,
Yes, you are free to use this as long as it complies to MIT License. However, I appreciate a mention about my Name and a link to this blog in your App, but its *not mandatory*.
Also, If you are fine, I could add your App’s App Store link, under whatever title you provide, in my blog as well as in Github README file.
Regards,
Bharath
Thanks. If I use in my app (still long way to finish and publish) I will provide you with details.
Hi, how would I implement this if I wanted a horizontal tableView ?? You know ? Like the way the sun is positioned on the sky throughout the day. I know about EasyTableView that has horizontal tableview scrolling.
This should do the trick..
mTableView.transform = CGAffineTransformMakeRotation(-90 * M_PI / 180.0);
HTH,
Bharath
i want to storyboard style
Very cool. I was looking for a way to have a table scroll at an angle when I came upon your post. Excellent work.
To get my angled scrolling I suppose one could rotate items in the cells and offset them in some constant way (not unlike your ellipse method, except in a line which would be simpler). Not ideal.
I’ll keep looking but if anyone knows how to have a rotated table that scrolls at that angle, I would appreciate a poke.
Troy,
Thanks. Do you have image that supports your description?
-
Bharath
This is a fantastic tutorial! What changes would need to be made to have this scroll around from the bottom of the screen? I’ve toyed with it a while, and it might be because I’m rusty on my math, but I can’t get it to work.
By Bottom of screen, do you the mean the first item be revealed from Bottom??
By bottom of the screen, I mean that the center point which all the objects rotate around would be located at the very bottom middle of the screen. Essentially what you have done from left & right side, but from the bottom! Thank you again!
Got it.. One solution that quickly comes to my mind is to use AffineTransformation to transform the tableview.. does it help?
Hi Bharath, I apologize for the late reply. I took the weekend off to clear my mind
Your suggestion does work! Thank you so much! However, I have found myself stuck on other features of this in order to tailor it to how I need it to appear. If you don’t mind, I would like to email you with some more details on what I am trying to accomplish with your fantastic demo! I believe what I am needing should be pretty quick for you to figure out