开发者

Grouped UITableView with vertical gridlines

开发者 https://www.devze.com 2023-04-01 08:50 出处:网络
I\'m trying to create UITableView with vertical gridlines, using method described here: http://www.iphonedevx.com/?p=153 . Everything works fine, until I switch table style to grouped.

I'm trying to create UITableView with vertical gridlines, using method described here: http://www.iphonedevx.com/?p=153 . Everything works fine, until I switch table style to grouped.

Vertical lines just don't appear on the table, though overridden drawRect: is still called.

What am开发者_Python百科 I doing wrong? Is there some major difference between cells for grouped and plain UITableView? Is it possible at all to draw primitives on the cells for grouped tables?

Thanks in advance.

PS: I'm using XCode 4, iOS SDK 4.3 and running the project with iPhone 4.3 simulator.


Just looking for the same. Found this guy's blog. It looks promising. He uses a custom png with the grid to complete the effect.


OK, I've found a solution myself.

  • I've subclassed UILabel, which represents a single cell in a grid. Override of drawRect: draws path with rounded corners and fills it with desired color. Background color of a label is set to clear color, otherwise no rounded corners for me.
  • Then I've subclassed a UITableViewCell that adds labels to itself. To simulate margins it adds offsets to labels' frame.origin.x and frame.origin.y.
  • All this stuff contained in a plain UITableView, but with margins and rounded corners it looks like a grouped one.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号