I have two labels in my UITableViewCell
and the constraints are set up so they are centered in the cell:
func setConsraints() {
// horizontal constraints
// vertical constraints
mainLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor, constant: someVariable).isActive = true
infoLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor, constant: -someVariable).isActive = true
}
But because the constant is a variable, sometimes it looks like:
I tried adding a constraint between mainLabel
and infoLabel
and played around with the priority but none of these solutions was working.
Question:
How can I add a "minimum" constraint to these two labels so they won't overlap each other but at the same time centering it to the UITableViewCell
, maintaining a certain distance?