문제 설명
UITableView의 테두리를 설정하는 방법은 무엇입니까? (How to set a border for UITableView?)
하나의 UITableView와 하나의 UIScrollView
로 구성된 보기를 만들었습니다. 이제 UITableView
에 대한 테두리를 그려야 UIScrollView
에서 분리할 수 있습니다.
참조 솔루션
방법 1:
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.
방법 2:
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.