My app will be using slightly thicker s开发者_如何转开发eparator 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?
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 :)
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
精彩评论