UITableView(iOS7)中的圆角 [英] Rounded corners in a UITableView (iOS7)

查看:129
本文介绍了UITableView(iOS7)中的圆角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS7中,如何在UITableView中绘制单元格的圆角?查看示例:

In iOS7, how can I draw cell's rounded corners in a UITableView? See an example:

推荐答案

您的 UITableview 包含 UIView ,所以只需使用下面的代码行来制作圆角。
在tableview方法中写下以下代码行

Your UITableview contains UIView, so just use this below lines of code for making it rounded corners. Also write this below line of code inside your tableview methods

//如果是iOS版本< 10

//If iOS version < 10

对于Objective-c: -

For Objective-c:--

   cell.contentView.layer.cornerRadius = 5;
   cell.contentView.layer.masksToBounds = YES;

对于Swift: -

For Swift:--

 cell.contentView.layer.cornerRadius = 5
 cell.contentView.layer.masksToBounds = true

//如果iOS版本> = 10

//If iOS version >= 10

对于Objective-c: -

For Objective-c:--

   cell.layer.cornerRadius = 5;
   cell.layer.masksToBounds = YES;

对于Swift: -

For Swift:--

 cell.layer.cornerRadius = 5
 cell.layer.masksToBounds = true

注意: - 无需明确导入 QuartzCore框架

Note:- No need to import QuartzCore framework explicitly.

这篇关于UITableView(iOS7)中的圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆