A UIImageView is added to a UITableViewCell using Auto-Layout.
The width of the UIImageView should be 50% of the width of the UITableViewCell but in any case not larger than 50px.
This does not work:
NSLayoutConstraint.activate([
cellImageView.topAnchor.constraint(equalTo: contentView.topAnchor),
cellImageView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
cellImageView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
cellImageView.heightAnchor.constraint(equalTo: cellImageView.widthAnchor, multiplier: cellImage.size.height / cellImage.size.width),
cellImageView.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.5),
cellImageView.widthAnchor.constraint(lessThanOrEqualToConstant: 50)
])
How do I have to define the layout constraints?