I have a grouped UITableView
and I have only one cell at section 0. I just want to hide the separator at the first section. If I use tableView.separator = [UIColor clearColor]
, it hides all separators. Any ideas?
While the original comment is generally the way to do this (roll your own subclass with a separator), iOS7 has given us a new pretty easy way to do it too.
With the addition of separatorInsets
on tables in iOS7, UITableViewCell
now has a separatorInset
property. By giving it a large value larger than the size of the table (such as UIEdgeInsetsMake(0, 320, 0, 0)
), you can effectively hide the separator by simply moving it off the screen.
The caveat is that the default, built-in views of a UITableViewCell
rely on the separator inset for the horizontal alignment of its content (so the content would also be off the screen and invisible). The way to fix this would be to build your own subviews instead, or set the x origin of the default ones you are using in the layoutSubviews
method of your UITableViewCell
subclass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With