繁体   English   中英

带有圆角的UITableView边框

[英]UITableView border with rounded corner

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

#import <QuartzCore/QuartzCore.h>

并添加到viewDidLoad

tableView.layer.borderColor = [[UIColor blueColor] CGColor];
tableView.layer.borderWidth = 5.0;
tableView.layer.cornerRadius= 5.0;

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

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

TableViewName.layer.borderWidth = 5;

TableViewName.layer.cornerRadius=5;

它可以为您提供圆角,而无需将表视图添加到superView或对其进行裁剪。

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

#import <QuartzCore/QuartzCore.h>

然后在ViewdidLoad中做

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

希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM