Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a border for UITableView?

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

like image 434
raghu Avatar asked Nov 25 '10 19:11

raghu


2 Answers

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

#import <QuartzCore/QuartzCore.h>

...

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

Also remember to include QuartzCore.framework in your project Frameworks list.

like image 174
Ari J.R. Avatar answered Nov 07 '22 14:11

Ari J.R.


There is another way to set the table boarder.

1.You just add the UIView whose size is little larger than table view. Add the table view as a subview of the view.

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

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

like image 43
iPhoneDv Avatar answered Nov 07 '22 16:11

iPhoneDv