I will like add a white view under all cell in to the UITableView, because TableView background is Clear Color, and when Cell N is one or two under these is clear.
Screenshot
I will like under these cells view color will white.
P.D. Sorry, my english is so bad. =(
You mentioned above that there are UIView elements on your UITableView background so setting he background color of it would not work, correct?
You could try setting the background color of the UITableViewCell itself, and add any of your custom views as subviews on the cell.
cell.backgroundColor = [UIColor whiteColor];
Try to set up tableview's footer view, and make it with a white background.
Related
I have a UITableView with 10 cells.
I've changed my UITableView's background color to red, but now there is a small red line between each cell (in addition to the separator line).
I need to disable this small gap between the cells that the background color won't be visible between the cells.
Screenshot:
Does anybody know how can I do this?
Thanks!
By going through your snap shot it is clear to me :
there is a separator which is a thin black line with custom offset set. That you can removed as mentioned in one of the answers.
other one is there is a red colour appearing in between cells. Please check is your tableView cell has clearcolor set. As you can see the last cell doesn't have red coloured line in bottom. Which i feel is you have a label over your cell which starts some pixel below the actual cell starts and hence you are able to see red coloured line over all cell excepts bottom of last cell.
In storyBoard select your tableView and then select "Attribute inspector"(at Right side) then Set "Seperator"->"None"
You can also do it by programatically -
UITableView property separatorStyle. Make sure the property is set to UITableViewCellSeparatorStyleNone and you're set.
example -
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
Try this in viewdidload:
self.tableview.backgroundcolor =[UIColor clearColor];
or
self.tableview.backgroundcolor =[UIColor whitecolor];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
I have created a bunch of cells which I reuse in a table view. All of those cells just have different UILabels inside them and some UIImageViews (nothing covers the complete cell).
Setting the background color in IB has no effect (always white or transparent, can't say which one of them). But if I press Command-R (simulate interface) the cell has the correct background color in the simulator.
I tried to set it in tableView:cellForRowAtIndexPath: but it doesn't work like I would think either.
This does the trick:
cell.contentView.backgroundColor = [UIColor redColor];
but these have no effect (even if I set the cell.contentView.backgroundColor to clearColor):
cell.backgroundView.backgroundColor = [UIColor redColor];
cell.backgroundColor = [UIColor redColor];
I set all the layout/font/background stuff in IB. Any idea why this isn't working in this case?
Why do I need to modify the contentView's backgroundColor and not the backgroundView's?
It seems to be a common issue. Could somebody please point me in the right direction to (finally) understand how background colors are handled within a table view cell.
To change the background color of the cell, you have to do it in the willDisplayCell:forRowAtIndexPath: method. This is mentioned in the UITableViewCell documentation near the bottom of the Overview. So you need:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor redColor];
}
The contentView is just the recommended subview to put custom controls in so that the cell gets layed out properly when table editing is going on.
There's an easier solution: When you create a UITableViewCell in Interface Builder, simply drag and drop an additional UIView so that it covers the entire UITableViewCell you're creating within IB. Place your additional UI elements on top of this additional UIView. You can set this extra UIView to whatever background you like.
There are quite a few answers on StackOverflow that suggest you change the background color of your UITableViewCell by using a line of code like this one:
cell.contentView.backgroundColor = [UIColor redColor];
If you add a drop shadow to your cell by adjusting the contentView's frame size slightly, you may find that this line will change both the background color of your cell and the color of your drop shadow area as well.
I am on iOS 8.
I add a view for the footer to stop empty rows at end of the UITableView with
- (UIView *)tableView:(UITableView *)tableViewIn viewForFooterInSection:(NSInteger)section
I have a custom separator colour for the table using
self.tableView.separatorColor = NAV_FG_COLOUR;
However the last row separator is defaulting back to white.
Any ideas welcome.
Make sure you have set clipsToBounds to YES in your UITableViewCell. Otherwise there could be double _UITableViewCellSeparatorView in your cell. One of those will have wrong color for last cell.
if clipsToBounds is YES already then this white color is the background color of UITableViewCell itself. Because last cell doesn't have separator at all when footer view is set up for the table. However height of contentView of your last cell is still 0.5pt less than height of cell. So that it makes visible background color of the cell itself.
use this to set the separator color
[self.tableView setSeparatorColor:[UIColor redColor]];
Is possible to create this separator style effect programmatically?
I have tried adding a uiview with an image created with photoshop but doesn't work very well.
Thank you
I would simply set separatorStyle = UITableViewCellSeparatorStyleNone and in the cell view add a UIImageView subview that has the separator you want at the bottom.
You can use a combination of separatorStyle and separatorColor on the table view. You can also add views with images or simply background colours and transparency to the top / bottom of your cells.
It looks like you could just set the tableView.separatorColor = [UIColor blackColor]; and add a 1px high view to the top of your cell with a white background and alpha = 0.1.
You can achieve this by setting a background image to your view and make tablecell seperator color [UIColor clearColor]
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
tableView.separatorColor = [UIColor colorWithRed:132.0f/255.0f green:132.0f/255.0f blue:131.0f/255.0f alpha:1.0f];
I want to make the scrollbar's background color clear, but I cannot find the property for it.
Just help me.
How are you coloring the cells? It looks like the contentView of the cell is being adjusted to fit the section index view. Try setting a backgroundView on the table cell with your background color.
Set UITableView background view as nil to make it transparent.
[tableView setBackgroundColor:[UIColor clearColor]];
tableView.opaque = NO;
tableView.backgroundView = nil;
Hope it helps you.