iOS - UITableViewCell 中文本周围的圆角矩形,如 Things 应用程序

标签 ios objective-c uitableview swift

我到处搜索,试图弄清楚如何实现在 iOS 设置应用程序和 Things for iPhone(CulturedCode 的应用程序,如下所示)中看到的效果。

在 iOS 设置中,当有可用的操作系统更新时,单元格最右侧的单元格中会显示 1,但该数字被深灰色的圆角矩形包围。

Things for iPhone 应用程序在收件箱单元格中的以下屏幕截图中具有相似之处:

enter image description here

如何使用 Swift 1.2 在 iOS 8 中实现这种效果?

最佳答案

使用标签。设置字体。将文本颜色设置为白色:

numberLabel.textColor = UIColor.whiteColor()

设置背景颜色:

numberLabel.backgroundColor = UIColor.grayColor()

设置角半径:

numberLabel.layer.cornerRadius = 5

剪辑到边界:

numberLabel.clipsToBounds = true

关于iOS - UITableViewCell 中文本周围的圆角矩形,如 Things 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29769884/

相关文章:

iphone - 将 Facebook 与 iOS 集成

ios - 页眉和页脚在电话间隙应用程序中消失了吗?

ios - 在 Objective C 中快速从 NSURL 下载到 NSDATA

iphone - 创建自定义 UIScrollView 滚动器

iphone - 在 cocoa 中的字符串上使用 MD5 哈希?

iOS - 如何在 TableViewController 中设置 TableView 的宽度?

ios - 无法加载 wikitude monotouch 绑定(bind)

ios - 无法使用 NSData :dataWithBytesNoCopy 进行复制

ios - 我们可以将 UITableView 添加到 Custom UITableViewcell 中吗?

swift - 我如何在 UITableView 内的 UICollectionViewCell 使用相同的代码?