spacing between cells io9.2 objective C - ios

I want to create spacing between table view cells like this:
I have 1 section and a dynamic number of rows per section for my tableview. So far I have set my content view to clear like this in my tableView:cellForRowAtIndexPath: method:
cell.contentView.backgroundColor = [UIColor clearColor];
I have also created a view within my content view, but I'm not sure how to set those values or manipulate the subview so that it appears as though there is spacing. If there's an easier way to create spacing I'm open to those suggestions as well.

Set the group background to clear color and the controller's background to the color you want.

1) Set the tableviews background colour to clear.
2) Set the cells background colour to clear as well.
3) Add a view(suppose "myView") with the background colour you need on top of the cell such that the height of the view is less than the rows height (e.g. myView.height = 90 and row height is 100).
4) Add the rest of your views as subviews of myView.
You will achieve your desired result.

Related

How to set UITableView background for blank space?

I attempted to use UITableView (with static content) to create a setting screen similar to the iPhone's system setting screen. It mostly works excepts the blank space under the last row are filled with white row cells instead of background color, as shown in this screenshot:
I have tried various ways to fix this: setting the table view's background, add an empty row as the last row with the background color. What should be the right fix?
Objective-C
[[UITableView alloc] initWithStyle: UITableViewStyleGrouped]
Swift 2
UITableView(style: .Grouped)
Swift 3
UITableView(style: .grouped)
You should also be able to set the table view style in the interface builder.
You need:
tableView.tableFooterView = UIView()
How to remove empty cells in UITableView?
Eliminate extra separators below UITableView
Go to View Section of the TableView's Attributes Inspector and set the background color there. It will work

ios tableView clearColor seperator

I have set my tableView's background color, and I want there is space(10px) around each cell show that color.
e.g.(ignore the red line)
What I am doing now is make the cell embed a smaller view, and set the cell's background to be clear. But it is annoying to create such embed view again and again.
So, I am seeking for a better solution, I believe it would be good if i can increase separator's height. But the old answers did not solve my problem.
(How to increase the UITableView separator height?)
EDIT:
However, if I add my own separator in cell. I may not able to set the cell having round corner
Set the tableView's separatorStyle to .None.
Create a custom UITableViewCell subclass.
In the storyboard (or xib if you created one for the custom cell), add a subview that's inset the amount that you want padded on all four sides.
If you want rounded views, do that on the custom cell's subview (e.g. subview.layer.cornerRadius = 10.0, subview.layer.masksToBounds = true).
Set the custom cell's ContentView to have a clear background.
Set the table view's background to that lovely shade of blue.
Set the cell subview's background color to white.
You don't have to use the cell repeatedly in InterfaceBuilder. Just give the cell an ID, and in your implementation of the table view's data source, dequeue a cell instance using that ID and set the values of the labels inside it.
Have you thought of just making the cell height taller and putting your own separator on the bottom of your custom cells? Nice table layout by the way.

heightForRow not equal cell height in UITableView?

I have created a viewController which displays a plain style UITableView. Sometimes I have enough cells to fill up the table view, sometimes I don't. When I don't have enough cells I want to make the table view smaller, in order to fill the rest of the screen with a view that displays the same background color as the color of my cells.
To do that I multiply the heightForRow with the number of cells that the table view is about to display. I have set the heightForRow to 70 and I have set the height of my custom cells to 70. This does make my table view smaller than even one of my cells.
Is the tableView height calculated in a different way, or what am I doing wrong?
EDIT: The answer below did not answer my question, but it solved my problem.
I use:
[yourtable setTableFooterView:[[UIView alloc] init]];

Control over clipping of the tableview footer/section

I have defined a footer section view for a tableview that i would like to be wider than my tableview. While i set the clipToBounds property to NO for my tableview my footer section is still being clipped. Is there a way to disable the clipping of the header/footer section for a tableview?
I believe the best approach for this is to have a custom background for your cells that would make them look narrower than the actual table view width.

Having an empty iOS tableview look (but when filled this changes)?

Hi I am attempting to create a rectangular region (tableView), that when it has no cells will be just a background color. Then when it has cells, the cell background can be different and separators become visible. This idea can be seen in http://itunes.apple.com/us/app/spendings/id473857206?mt=8
in the second screen shot. I can come close by just setting the background color of the table and the cells to different colors, but when there are no cells the table collapses. The screenshot in that link doesn't show this, but when there are no items, it is just an empty rectangle. How can one maintain the dimensions of the table, even when there are no cells?
You can try setting the separator color to clearColor so that the cells aren't visible when they're empty, like:
if([tableView numberOfRowsInSection:0]==0)
{
tableView.separatorColor = [UIColor clearColor];
}

Resources