Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uitableviewCell Separator line

Hi I'm new to ios development. I am developing an application in which I am using UITableView. Tableview contains some cells with separator line and others without separator line. Can any one please tell me how can I remove separator line for specific cell?

cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, cell.bounds.size.width);

Above code works for iOS 7. How can I achieve this in iOS6? Any help is appreciated

like image 249
Shital Tiwari Avatar asked Apr 07 '14 11:04

Shital Tiwari


1 Answers

You can just add a UIView with the same background color as you want your separator line to be at the top of your UITableViewCell layout, make its height one pixel (it will be the same as a line) and its width the same as your cell width (cell.frame.size.width). After this in your cellForRowAtIndexPath just set hidden property of this to YES for the cell you don't want it to be shown and hidden = NO for those you want. It is a simple solution which will work in any iOS version. But if will add your custom separator don't forget to disable default separators for all tableview

like image 124
Oleksandr Karaberov Avatar answered Oct 18 '22 04:10

Oleksandr Karaberov