iosuikitautolayout

Why does UIImage with SymbolConfiguration change UIImageView frame?


I am making UIImageView with UIImage.SymbolConfiguration.

let config = UIImage.SymbolConfiguration(font: .preferredFont(forTextStyle: .title1))
imageView.image = UIImage(systemName: "person", withConfiguration: config)

Then setting up constraints:

imageView.widthAnchor.constraint(equalToConstant: 55.0),
imageView.heightAnchor.constraint(equalToConstant: 55.0),

But instead I see frame is (8 10.3333; 55 51) instead of (8 10.3333; 55 55).

Why is this and how to fix it?


Solution

  • One solution could be to use the insets from the image view to offset the position, canceling it out.

    Another is to make an image view subclass that always returns .zero.