简体   繁体   中英

UILabel max height with AutoLayout

I have a multiline UILabel inside a custom keyboard extension. I want this label to grow to fill the content up to a certain height, at which point I want it to just cut off the rest of the text.

Because the keyboard has different heights depending on the device and orientation, I can't just set a simple less than or equal height constraint .

What I tried was to constrain the bottom of the label to the top of the buttons below, with a greater than or equal constraint . This works to a certain extent, but causes the keyboard to grow in size as opposed to the label being forced to cut off its text.

How would I force the label to a max height, without directly using a height constraint on the label?

将标签放在UIView ,并将视图的高度限制为less than or equal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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