有没有办法自定义UITableView的分隔线图形?
我正在寻找自定义 UITableView 的分隔线图形。 它基本上是一条线,并且可以隐藏。但我不知道如何用我自己的自定义图形或图像绘制分隔符。有常规方法可以做到这一点吗? 或者我必须自己绘制所有内容并手动管理它们?
I'm finding customizing UITableView's separator line graphics.
It's basically a single line and it can be hidden. But I cannot know how to draw separator with my own custom graphics or image. Is there a regular way to do this?
Or do I have to draw all myself and manage them manually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种简单的方法是隐藏分隔符并将您自己的分隔符嵌入单元格的背景图像中。
如果需要绘制自己的分隔符,则需要重写
-[UITableView _drawExtraSeparator:]
或-[UITableViewCell _drawSeparatorInRect:]
或-[_UITableViewSeparatorView drawRect:]
。这些都是未记录的,所以不要考虑在AppStore中使用它们。A simple way is hide the separator and embed your own separator in the cell's background image.
If you need to draw your own separator, you need to override
-[UITableView _drawExtraSeparator:]
or-[UITableViewCell _drawSeparatorInRect:]
or-[_UITableViewSeparatorView drawRect:]
. These are all undocumented so don't think about using them in the AppStore.