[英]How can I truncate a UILabel next to a UIImage using autolayout/storyboard?
I have a UILabel next to a UIImage where I want the UILabel to be show truncated "..." if it starts to overlap with the neighboring UIImage. 我在UIImage旁边有一个UILabel,如果UILabel开始与相邻的UIImage重叠,则我希望该UILabel显示为“ ...”。
Text is behind the UIImage when i want it to just truncate: 当我想要截断文本时,文本位于UIImage的后面:
My UILabel properties: 我的UILabel属性:
I thought the issue is the content compression but I set the UILabel's content compression resistant priority horizontal to 250 and the UIImage to 1000. This only hides the UILabel behind the UIImage. 我以为问题是内容压缩,但是我将UILabel的耐内容压缩优先级水平设置为250,将UIImage设置为1000。这仅将UILabel隐藏在UIImage后面。
*This is inside a table cell. *这在表格单元格内。 I'm not using the default table cell view because i intend to customize it further.
我没有使用默认的表格单元格视图,因为我打算进一步对其进行自定义。
从UILable到UIImage的尾随添加常量值5,并且关系小于和等于(<=)。
Three things can be done. 可以完成三件事。
Add constraint between: 在以下之间添加约束:
1) UIImage and the table cell (the container view) 1)UIImage和表格单元格(容器视图)
2) UILabel and the UIImage 2)UILabel和UIImage
3) and finally one between tableCell and UILabel 3)最后是tableCell和UILabel之间的一个
This way you will have your UILabel stretching from the left side of the cell all the way to the image view, and truncate the text that doesnt fit into the label. 这样,您将使UILabel从单元格的左侧一直延伸到图像视图,并截断不适合标签的文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.