简体   繁体   English

UILabel自动布局切割底部像素

[英]UILabel autolayout cut bottom pixels

I constructing UITableCellView from xib. 我构建UITableCellView从厦门国际银行。 This xib uses autolayout and two UILabel s connected to superview and have vertical constraint. 此xib使用自动autolayout和两个UILabel连接到autolayout并具有垂直约束。

Unfortunately it is cutting pixel(s) at the bottom of UILabel : 不幸的是,它正在切割UILabel底部的像素: 在此输入图像描述

What do I missing? 我错过了什么?

UPD. UPD。 Xcode is giving me error: Set vertical compression resistance priority to 749 . Xcode给我错误: Set vertical compression resistance priority to 749 If I play with compression resistance priority I get first label cut. 如果我使用抗压优先级,我会先得到标签。

Set the priority on the vertical spacing constraint between the two labels to be lower than the vertical spacing constraint between the labels and the top and bottom of the view. 将两个标签之间的垂直间距约束的优先级设置为低于标签与视图顶部和底部之间的垂直间距约束。 Alternatively, in your delegate, override 或者,在您的委托中,覆盖

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath

and

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

that will return a height that will accommodate the constraints and label heights. 这将返回一个高度,以适应约束和标签高度。 By default I believe you get 44 pixels, so you can get a taller cell by overriding these. 默认情况下,我相信你会得到44个像素,所以你可以通过覆盖它们来获得更高的单元格。 Also, you can set the cell height in IB if you're using Storyboards or Nibs. 此外,如果您使用的是Storyboard或Nib,则可以在IB中设置单元格高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM