I'm trying to implement a TableView with expandable cells. When a cell is selected I change the height of the cell to show the rest of the content. The problem is that when the cells are collapsed, they are transparent and all of the content is visible through the lower cells. How can I make these cells opaque?
If I understand your problem, it's not that the cell is transparent, it's that the subviews are visible outside the bounds of the cell. You can eliminate that by setting the clipsToBounds property for your cell to YES. You can do that in code, or in IB by selecting the "Clip Subviews" checkbox.
Related
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.
I have an UITableView with varying height, and when pressing reorder control, in the cell view structure a new view appears. Normally it is not a problem, but sometimes its height is quite big, and it overlaps, with cell below.
Why this view appears?
How can I get rid of it?
Or prevent to overlap other cells?
This view is part of the reorder mechanism and can't be removed. It is used to hide the cell content while you drag a screenshot view above the tableview.
If you set the cell clipsToBounds as YES, it should prevent it's content overlapping other cells.
I have an UITableView that does not fill the whole screen, so there is some space at the top and the bottom of the screen. This table uses table.clipToBounds = NO and table.bounces = YES.
But when scrolling the cells outside the original frame of the table, the cells are hidden. I know that's the normal behavior of UITableView to increase performance. But is it possible to define an area at the top/bottom of UITableView within which the cells are not hidden? Or even set a cell property to be "always" visible?
Subviews outside bounds of superview are hidden (table view's cells are also its subviews). That's just how iOS view hierarchy works, not really about performance. And it doesn't make any sense when a subview/cell is displayed on the screen while user cannot interact with it (because it's out of bounds). In particular, table view reuses cells that go out of its bounds, so no, you cannot set a cell to be "always visible".
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.
I have a uitableview and when I put it in the edit mode and reorder the cells , the native ui shows the cells separators/shadow while I drag the cell.
Is there a way to drag the cell without the shadow being visible ?
I have already set the setSeparatorStyle:UITableViewCellSeparatorStyleNone on my table view, however the shadow is still visible for cell being dragged.
Thanks!