BergP
BergP

Reputation: 3545

NSLayoutConstraint in UICollectionViewCell: Size Class Customization doesn't work

I'm trying to customize size of the image inside my UICollectionViewCell, but I haven't managed to achieve the result yet.

here is my cell

enter image description here

and here is inspector for the height constraint

enter image description here

What am I doing wrong?

Update:

I've just noticed some logs

(
    "<NSLayoutConstraint:0x78fcab10 V:[UIImageView:0x78fcaa00(129)]>",
    "<NSLayoutConstraint:0x78fcb100 V:|-(8)-[UIImageView:0x78fcaa00]   (Names: '|':UIView:0x78fca940 )>",
    "<NSLayoutConstraint:0x78fcb130 V:[UILabel:0x78fcac40'Completed all MEDIUM quiz...']-(8)-|   (Names: '|':UIView:0x78fca940 )>",
    "<NSLayoutConstraint:0x78fcb190 V:[UIImageView:0x78fcaa00]-(8)-[UILabel:0x78fcac40'Completed all MEDIUM quiz...']>",
    "<NSAutoresizingMaskLayoutConstraint:0x79195380 h=--& v=--& V:[UIView:0x78fca940(50)]>"
)

But I do not understand how NSAutoresizingMaskLayoutConstraint appears here.

Upvotes: 0

Views: 170

Answers (1)

Doro
Doro

Reputation: 2413

From your screenshot:

  1. you aligned image horizontally and added leading constraint. remove it, if you want to have fixed image size.

  2. if you want your view to automatically resize image (by width) - remove width constraint & horizontal align and add trailing constraint.

It depends on goal.

Hope this helps

Upvotes: 1

Related Questions