简体   繁体   中英

Using Auto-Layout in custom UITableViewCell

I'm working with a custom UIableViewCell that has four UILabel s inside of it.

What I'm currently struggling with is that for smaller iPhones, I'm able to get the correct portrait layout (the numbers correspond to the label numbers).

在此输入图像描述

What I'm trying to do for larger iPhones (screenshot below is from a 6SPlus) is have label 3 move in the direction of the arrow:

在此输入图像描述

I have three constraints for the third label. My thought was to have one of them set with a priority of 1000 to be the "base constraint", and another, set at 999, to change the spacing of the cell:

在此输入图像描述

However, it doesn't seem to have any effect. How can I alter the position of the third label using constraints based on the size class? Thanks!

EDIT: This is an approximate illustration of what I'm trying to get to:

在此输入图像描述

Use a UIStackView and put your labels inside it. The stack view can be configured to distribute evenly your four labels, putting the same amount of space between them regardless of how the width of the table grows or shrinks as it launches on a bigger or smaller phone. Thus, you'll look great everywhere.

(If you're not able to use UIStackView, you can achieve the same effect of even distribution using invisible spacer views.)

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