How to reduce padding between each table view cell - ios

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.

Related

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

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.

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

Best approach to achieve this grid layout on iOS

A question for the UICollectionView experts.
Imagine a collection view that looks like a table view (full width cells), and when you tap on one of them, new cells are inserted underneath that cell that are square cells, say half the width of the collection view, in 2 columns. Tapping the header again would appear to collapse the section.
Keeping in mind that I’m trying to use UICollectionViewFlowLayout instead of a custom UICollectionView.
Would you:
A) implement the tableview style cells as collection view supplementary views (headers), with a gesture recogniser that inserts the square cells?; or
B) implement the tableview style cells as one cell type, and the square cells as another cell type?; or
C) something else?
Personally I would go with option A. In the situation you're describing the full width item is really a section header that's function is to show/hide it's sections's cells.
From a data structure standpoint this is much easier to maintain with this approach. It can be handled with an array of arrays.
If they were all cells it would most likely be one large array, and would be more difficult to make the distinction between a full width cell and the half width cells.

Kind of complicated custom UITableViewCell

I have a particular goal in mind here, searching for it is a little hard. I am trying to accomplish this (This is a photoshopped screenshot):
I have everything in this view working, except for the split row for the Company Name/ Beginning of the field row. The "Company Name" field is just a textfield, all I really want to do is shrink that neato cell background to just go behind the right side.
Create a custom table view cell that has two subviews: the text field on the left and a UITableViewCell on the right as a subview of the main table view cell. A UITableViewCell is just a UIView so you can actually add it as a subview of any view. The main table view cell will have it's background color set to transparent.
So totally complicated custom cell comes with a totally ridiculous solution. I built a view for the cell that has the one field...and another UITableView.
That second UITableView has the "Beginning of the field" text, and its cell gets the background, and I hide the background of the main cell.
I had to play around with the nested table's size and position to get the row to display properly, and make sure that the lines in the background don't shift when it hits the nested table, but it came out perfect
You could try setting the frame property of your cells backgroundView to cover only have your cell's width. Address Book handles complex forms like this with a nice look and feel--you might want to see what they've done there..
One approach would be to define a custom table view cell, set its background transparent and add the UITextField on the left and a UIButton on the right (customize it to look like your other cells), as in your screenshot.

Resources