UITableView Section Border

Can I set a border in a UITableView (group style) section? I do not want to change the border of the cells in the section - I need a border around the entire section. Like this:

Bordered UITableView section

Note Although the above figure shows only part of one section, the table in question actually has several sections, each of which has a variable length, which I would like to separate separately.

+6
ios uitableview
Mar 19 '12 at 15:47
source share
1 answer

Yes, you can achieve this with a couple of lines of code:

Just just a TableView in your Xib file. No need to have a UITableView style to group.

1) Import the QuartzCore environment into your .h file.

#import <QuartzCore/QuartzCore.h> 

2) Now set the TableView layers in the .m file.

 [CategoryTblView.layer setBorderWidth: 1.0]; [CategoryTblView.layer setCornerRadius:8.0f]; [CategoryTblView.layer setMasksToBounds:YES]; [CategoryTblView.layer setBorderColor:[[UIColor blackColor] CGColor]]; 

And this is the result:

enter image description here

-2
Mar 19 '12 at 17:57
source share



All Articles