带圆角的UITableView边框

时间:2016-05-21 10:58:21

标签: ios objective-c uitableview

如何在UITableView上显示圆角半径(例如:5)的边框(宽度:5,颜色:任意)?

3 个答案:

答案 0 :(得分:3)

#import <QuartzCore/QuartzCore.h>

并在 viewDidLoad

中添加此内容
tableView.layer.borderColor = [[UIColor blueColor] CGColor];
tableView.layer.borderWidth = 5.0;
tableView.layer.cornerRadius= 5.0;

答案 1 :(得分:1)

首先导入QuartzCore框架(例如:#import <QuartzCore/QuartzCore.h>),然后使用此代码,

TableViewName.layer.borderColor = [UIColor redColor].CGColor;

TableViewName.layer.borderWidth = 5;

TableViewName.layer.cornerRadius=5;

它将为您提供圆角,而无需将您的tableview添加到superView或剪切它。

答案 2 :(得分:0)

需要在项目中添加QuartzCore Framework 然后在类中导入框架,如下所示

#import <QuartzCore/QuartzCore.h>

然后在ViewdidLoad中执行

yourTableViewName.layer.borderColor = [UIColor gray].CGColor;
yourTableViewName.layer.borderWidth =  3.0;
yourTableViewName.layer.cornerRadius = 3.0;

希望这有帮助!

相关问题