views:

339

answers:

3

My app will be using slightly thicker separator lines in tableViews - about 3x the thickness. I have already done this in some areas by setting separatorStyle to none and customizing cell backgroundViews with custom backgrounds that include my thick separator.

The issue with this method is that it only applies to real rows. Thus if I have a tableView that fills the whole screen but only has two rows, then only the two rows will have the custom separators. The workaround I've been using is to create blank cells (with the custom background) whenever the actual rows don't fill the entire table. However, this workaround is not feeling very practical.

Things would be much simpler if I could either modify the default separator's thickness...is there any way to do this, or something similar?

A: 

I have answered a relevant question here.. Go in the drawRect Method and just increase the line width according to your needs.

Do remember that this code is for grouped tables and you have to modify the code a little bit for your tableview(if you are using plain table.)

Hope this helps.

Thanks,

Madhup

Madhup
Thanks for the response. However, looking at your code, it looks like you are customizing a UITableViewCell's background. My question pertains to the separators that appear on a (plain)tableView even if numberOfRows = 0. In this case, cellForRowAtIndexPath never gets called, but the tableView still draws the appropriate separator lines.You gave me an idea though...perhaps I could customize the drawRect: method of the tableView so that it draws a thicker line on top of the standard separator lines. That probably ends up being too much work for what I'm doing though.
iPhoneToucher
+1  A: 

Well I figured it out. It's actually quite simple, but there's bad news and good news. The bad news is that the separators are actually their own view classes added as subviews to the tableView, and these classes are part of Apple's undocumented API. Thus, any modification of them wouldn't sit well with Apple.

The good news is that you don't need to do anything with the undocumented classes in order to thicken the separator lines. You can simply add in your own subviews as separators. Personally I'd rather have the lines drawn in as opposed to using the subview mechanism (since all the new subviews could potentially make a large table choppy), but since we don't have access to _UITableViewSeparatorView, I'll take what I can get :)

iPhoneToucher
How do we create our own separator? Would you mind posting the code to your solution?
Tony
A: 

iPhoneToucher, Could you please post the code for adding your own subviews for the UITableViewSeparators?

Thanks,

Andrew

KingAndrew