有没有办法修改UITableView的分隔单元格? [英] Is there any way to modify a UITableView's separator cell?

查看:158
本文介绍了有没有办法修改UITableView的分隔单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式将在tableView中使用略厚的分隔线,约为厚度的3倍。我已经在一些区域通过将separatorStyle设置为none和自定义的backgroundViews自定义背景,包括我的厚分隔符。

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.

这个方法的问题是,它只有适用于实际行。因此,如果我有一个tableView填充整个屏幕,但只有两行,那么只有两行将有自定义分隔符。我一直在使用的解决方法是创建空白单元格(使用自定义背景),只要实际行不填满整个表。然而,这种解决方法不是很实用。

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?

推荐答案

这其实很简单,但有坏消息和好消息。坏消息是,分隔符实际上是作为子视图添加到tableView的自己的视图类,这些类是Apple的未记录的API的一部分。因此,对它们的任何修改都不适合与苹果。

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.

好消息是,你不需要做任何与无证的类,以加厚分隔线。您可以简单地将自己的子视图添加为分隔符。个人而言,我宁愿有线绘制,而不是使用子视图机制(因为所有新的子视图可能会使一个大表乱舞),但由于我们没有访问_UITableViewSeparatorView,我会采取我可以get:)

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 :)

这篇关于有没有办法修改UITableView的分隔单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆