How to set border for UITableView?

I created a view consisting of one UITableView and one UIScrollView , now I need to draw a frame for the UITableView so that it can be isolated from the UIScrollView .

+6
ios objective-c uitableview
source share
2 answers

Check out the UIView layer property, which allows you to define the visible border for the view. Try the following:

 #import <QuartzCore/QuartzCore.h> 

...

 self.yourtableview.layer.borderWidth = 2; self.yourtableview.layer.borderColor = [[UIColor whiteColor] CGColor]; 

Also be sure to include QuartzCore.framework in your Frameworks project.

+19
source share

There is another way to set the table border.

1.You just add a UIView that is slightly larger than the table view. Add a table view as a subview of the view.

Like, if the table frame size is (2,2,100, 200), then the view size should be (0,0,104,204).

2. Set the backgroundColor view as you want to set the border color.

+1
source share

All Articles