ios - 编程约束切断了我的标签底部
问题描述
我有一个带有根UITableViewCell
和子的 Nib 文件UILabel
,我在运行时使用编程约束锚定它
lblAccountItemTitle.translatesAutoresizingMaskIntoConstraints = false
lblAccountItemTitle.topAnchor.constraint(lessThanOrEqualTo: self.topAnchor, constant: 16).isActive = true
lblAccountItemTitle.bottomAnchor.constraint(lessThanOrEqualTo: self.bottomAnchor, constant: -16).isActive = true
lblAccountItemTitle.leadingAnchor.constraint(equalTo: imgAccountItemLeft.trailingAnchor, constant: 16).isActive = true
lblAccountItemTitle.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -32).isActive = true
lblAccountItemTitle.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
另外,我注意到我的底部锚点越短,文本的剪辑就越少
如何在保持相等的 16 个垂直填充的同时摆脱剪裁?
解决方案
将图像和标签底部锚点从equalTo 更改为lessThanOrEqualTo
lblAccountItemTitle.bottomAnchor.constraint(lessThanOrEqualTo: self.bottomAnchor, constant: -16).isActive = true
推荐阅读
- scala - Spark Dataset joinWith API 给出错误结果
- python - volatile 已被删除,现在没有效果。改用`with torch.no_grad():`。输入变量=变量(输入,易失性=真)
- javascript - 如何使用 Composer 安装的 Javascript 或 CSS 文件?
- android - React Native - 如何获取选择器数据
- bash - 如何使用 bash 读取 yaml 或 env 文件
- sharepoint - Sharepoint 2013 工作流程:将任务状态设置为完成会导致其他任务消失
- c - 如何在 C 中使用指针访问结构成员?
- php - 如何在 php formmail 中启用 UTF-8 字符编码
- javascript - 如何在网格布局中定位最底部的容器
- go - github.com/jinzhu/gorm 和 gorm.io/gorm 有什么区别?