Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel autolayout cut bottom pixels

I constructing UITableCellView from xib. This xib uses autolayout and two UILabels connected to superview and have vertical constraint.

Unfortunately it is cutting pixel(s) at the bottom of UILabel: enter image description here

What do I missing?

UPD. Xcode is giving me error: Set vertical compression resistance priority to 749. If I play with compression resistance priority I get first label cut.

like image 325
Eugen Martynov Avatar asked Jun 23 '14 14:06

Eugen Martynov


1 Answers

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. Also, you can set the cell height in IB if you're using Storyboards or Nibs.

like image 126
Sandy Chapman Avatar answered Oct 10 '22 21:10

Sandy Chapman