Nic Hubbard
Nic Hubbard

Reputation: 42139

Don't let UILabel overlap another label in UITableViewCell

I have a custom UITableViewCell that has a titleLabel on the left, and a detail label on the right, similar to the Right Detail cell type.

enter image description here

Current neither UILabel has a set width, which is what I want. However the titleLabel sometimes is very long and overlaps the detail label on the right.

How can I give a margin between the two labels, ONLY if the titleLabel is too long and will overlap?

Upvotes: 1

Views: 863

Answers (1)

Pavel Gatilov
Pavel Gatilov

Reputation: 2590

The thing what you can do, is set minimum space between them by putting relation GraterThenOrEqual for example at 10 pixels. Or there is a dodgy way to it by playing with priority with constraints. You may set priority of constraint between as 750.

In the interface builder you have to set space between the labels, and then select manually this constraint, then you will see the menuenter image description here

called Relation, just choose there GraterOrEqual

Upvotes: 1

Related Questions