iOS - Add border around a collection view cell and a view under it - ios

There is a collection view cell and a view of the same size right under it.
Instead of separately adding two circle borders for both the cell and the view, I want to add one for them together (forming a rounded rectangle)
Is this possible?
If yes, how to handle the scrolling of the collection view?

Yes it is possible but tricky.
I'd suggest you really try to combine it into one cell to avoid lots of headaches.
If you can not then you need to toy with the collection view layout to get your cell to line up correctly with the view underneath and you need to figure out the scrolling as you indicate.
I've sometimes had to use two consecutive collection view cells that needed to align and it was terrible to get it right, thus I suggest try to solve this problem using just a single cell. FWIW the last cell in a collection view often shifts slightly compared to the others so I've sometimes added a blank cell last just so my second to last will align correctly.

Related

How to reduce padding between each table view cell

Is it possible to reduce the padding surrounding each table view cell in a table view? I understand I could do this through a custom solution but I would like to have the default auto-resizing behavior of a standard table view cells but just reduce the padding between cells.
I'm not sure if I completely understand your question, but when working with table view cells, I generally
Get rid of the line operator
Set the background color of the cell and the table view to be the same
Create a subview that is essential all the design of the cell
By doing this I can make the subview a different color and increase or decrease its size, and in a way, it acts as padding between cells.
Again I'm not totally sure if that helped, but if it and you would like the code for that just respond to my answer.

UICollectionViewCell Shadow on all four sides

I was wondering want the best way to add drop shadows to a set of collectionviewcells that do not have spaces between them?
Background
Part of my layout has various cells positioned across the screen like a post. It notes and the second half of the layout is structured to look like a tableview except all the cells don't go to the edges there's a bit of padding. So I can't really add a shadow around the collection view itself.
I have added shadows to the cells in the post. It note part which works great because the cells have spaces between them but I'm now struggling with the second half (the tableview looking part) because obviously when you add the shadows to the cells depending on the zIndex you may see the shadow overlapping the below or top cell.
So I was wondering what is the best way to do this?
Should the shadows decoration views underneath the cells?
OR
Should the shadows be attached to the cell and increase the ZIndex for each cell so they appear on different levels hiding the shadow - but that leads to a question on how to do the first cell and have a top shadow?
OR
Should I almost fake it by using an image of a shadow inside the cell itself?
I also have deletion functionality so I need to figure out how to make sure if I delete the first cell, the second cell should then have the top shadow in a nice animated way.
EDIT:
I am trying to create the following view inside the collection view. I have got the layout correct. 1
The green lines are the shadows I have working but the red are the ones I'm having trouble with and the boxes are the different cells.

iOS StackView or CollectionView

I have to make a grid with a specific architecture.
I don't know if I have to use a stackView with views? Or a collectionView with cell?
Let's see my image :
Green cells will be repeated infinite times.
Thanks for your help!!
The easiest and best way do make this is collection view, Also in collection views cells(items) are reused, so you don't need to release them after they have disappeared.
It depends on the number of grid cells. If the number of cells is 2~4, it's OK to use stackView.
But
Green cells will be repeated infinite times.
So, you should use collection view. Collection view is suitable for displaying repeating layouts like your image or calendar app on iOS.
And offscreen collection view cell(table view cell also) is reusable, so you only create cells enough to fill the screen and a little more.
See Table View Cell Reuse Explanation

iOS Collection View Cells: Strong references during reuse / prevent cell reuse?

Question: What happens to references to a collection view cell when it is scrolled offscreen and reused? All my attempts to supply cells without using "dequeue" have failed. Is there a way to tag a cell as non-reusable, so the collection will keep it around? I want to tell the collection "Hey, don't reuse this cell yet!".
Long story: I have a collection view where each cell has a collection view in it. I am using a custom layout (https://github.com/lxcid/LXReorderableCollectionViewFlowLayout) on the sub-collection views to enable dragging and reordering of cells, but I want to extend this to allow dragging cells from one collection view into another. I have it working, except that if a cell is dragged from a collection view that is then scrolled offscreen during the drag, it breaks because the layout handling the gesture, and its collection view, have been reused. The cell with the collection view and reorder-able layout is still doing work, and I need it to not get reused.
Thanks for sharing the long story. It helps to see what you're trying to do. I can understand your approach and can see why you might initially think this is a good logical approach.
However, I'll try to convince you to try to use another approach. The common approach is to take a snapshot of the view during the drag, then add it to the superview and move it around with the drag from one collection to another. Let me know if this approach makes conceptual sense.

How to implement those tables please

I have to implement the tables below
I know I can use custome cell with two labels but any idea how to implement the overall shape with the vertical and horizontal labels
Maybe set up a regular view controller. Then add a collection view, make the cell very large. In that collection view cell add a label on the side (this will become the light blue box). Then right next to it add a table view with sections. The header would be the red and dark blue area.
This would work, but you need the flexibility of starting as a view controller, and doing the collection and table view through delegates
Your question is too broad and cannot be answered in such form.
It's a customized UITableView created by Subclass-ing the UITableViewCell.
Check these tutorials and third-party controls:
Horizontal TableView
MDSpreadViewDemo
KKGridView

Resources