大佬教程收集整理的这篇文章主要介绍了ios – 如何截断UITableView Cell TextLabel中的文本,以便它不会隐藏DetailTextLabel?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
对于某些字符串,textLabel太长并且detailTextLabel变为隐藏状态.是否有设置自动调整文本…如果它太长了?
以下是中非共和国(移动)有此问题的示例:
override func layoutSubviews() { super.layoutSubviews() if let detail = self.detailTextLabel { // this will do the actual layout of the detail // label's text,so you can get its width detail.sizeToFit() // you might want to find a cLever way to calculate this // instead of assigning a literal let rightMargin: CGFloat = 16 // adjust the detail's frame let detailWidth = rightMargin + detail.frame.size.width detail.frame.origin.x = self.frame.size.width - detailWidth detail.frame.size.width = detailWidth detail.textAlignment = .Left // Now truncate the title label if let text = self.textLabel { if text.frame.origin.x + text.frame.size.width > self.frame.width - detailWidth { text.frame.size.width = self.frame.width - detailWidth - text.frame.origin.x } } } }
以上是大佬教程为你收集整理的ios – 如何截断UITableView Cell TextLabel中的文本,以便它不会隐藏DetailTextLabel?全部内容,希望文章能够帮你解决ios – 如何截断UITableView Cell TextLabel中的文本,以便它不会隐藏DetailTextLabel?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。