Ios 为uitableview创建边框
我正在uiview中使用uitableview和scrollview。如何设置表格或滚动视图的边框Ios 为uitableview创建边框,ios,objective-c,ipad,Ios,Objective C,Ipad,我正在uiview中使用uitableview和scrollview。如何设置表格或滚动视图的边框 #import "QuartzCore/QuartzCore.h" 然后在viewDidLoaduse中 tableView.layer.borderWidth = 2.0; 注意 您还可以设置边框颜色: tableView.layer.borderColor = [UIColor redColor].CGColor; 它应该适合你。:) 这对我来说非常有效: CALayer *layer
#import "QuartzCore/QuartzCore.h"
然后在viewDidLoad
use中
tableView.layer.borderWidth = 2.0;
注意
您还可以设置边框颜色:
tableView.layer.borderColor = [UIColor redColor].CGColor;
它应该适合你。:) 这对我来说非常有效:
CALayer *layer = _tableView.layer;
[layer setMasksToBounds:YES];
[layer setCornerRadius: 4.0];
[layer setBorderWidth:1.0];
[layer setBorderColor:[[UIColor colorWithWhite: 0.8 alpha: 1.0] CGColor]];
圆形边框看起来更像iOS
如果要为tableview指定颜色边框,请使用以下代码
斯威夫特3
正如您所期望的,还有一个tableView.layer.borderColor属性(CGColorRef)。tableView.layer.borderColor=[[UIColor redColor]CGColor]。这也有效,谢谢它有效!我们可以在图层上添加一个按钮,让它显示在前面吗?
yourTableViewName.layer.borderColor = UIColor.gray.cgColor
yourTableViewName.layer.borderWidth = 1.0