I've a Swift UIKit Component with dynamic sizing, am I required to specify it's width and height anchors in the parent view? If yes, then how?
I fixed it. Basically, inside my UIView, I had a UIButton which had a UIImage, and as I specified the UIImage was an SF Symbol with size, which I calculated like this: UIFont.preferredFont(forTextStyle: .title1).pointSize
, note: the .title1
can be any UIFont.TextStyle
value.
Then what I did was, I created a Utility Method inside my UIView class, which basically returned UIImage.size
, and then I called this inside my constraints method in the parent view, and the set the width and height anchor to the value from this variable.
Everything works as expected now!