raghu
raghu

Reputation: 61

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.

Upvotes: 6

Views: 10322

Answers (2)

iPhoneDv
iPhoneDv

Reputation: 1969

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.

Upvotes: 1

Ari J.R.
Ari J.R.

Reputation: 471

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.

Upvotes: 19

Related Questions