Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to add multiple diagonal connection lines between TableViewCells

I'm creating an app that needs to show a tableview like below image enter image description here

Similar colored circles are to be matched with a line.

Which view i can add the lines? Or need to create a new view above tableview? But still my tableview needs to be scrolled.

How can i achieve this?

Update for Bounty

I want to implement the same with incliend lines between neighbouring circles. How to achieve the same?

Demonstration below:

enter image description here

like image 362
Saranjith Avatar asked Aug 21 '17 10:08

Saranjith


4 Answers

create design like this

enter image description here

Based on your requirement just hide upper line and lower line of circle

like image 80
Divyesh Gondaliya Avatar answered Oct 21 '22 15:10

Divyesh Gondaliya


You need to create collection view in tableview cell. In collection view you create one cell. Design the same user interface like your design. Show and hide the view with matching of rule. It will not affect tableview scrolling. and with this approach you can also provide scroll in collection view cell. i can provide you coded solution if you able to provide me more information. Thanks

You can use this Third Party LIb

like image 29
Waqas Sultan Avatar answered Oct 21 '22 17:10

Waqas Sultan


You need to use a combination of collection view and a table view to give support for all devices.

1.Create one collection view cell with following layout

Custome Collection view cell

  1. Hide upper and lower lines as per your need

  2. Add collection view in table view cell and managed a number of cells in collection view depending upon the current device width and item's in between spacing.

like image 22
KavyaKavita Avatar answered Oct 21 '22 16:10

KavyaKavita


You can create a vertical label without text, set the background color with black and place it behind the circle in view hierarchy and set a width of the label as per your requirement. Then you can hide unhide the label whenever you want.

P.S.: Make sure to hide your cell separator.

I have created a demo project. You can find it here. I tried to match your requirements. You can update the collection view settings to handle the hide and show of labels.

Let me know if you have any questions.

Hope this help. Thanks!

like image 23
Akshay Sunderwani Avatar answered Oct 21 '22 16:10

Akshay Sunderwani