I have a subclass of UIView on which the user can add random CGPath. CGPath is added by UIPanGestures processing.
I would like to resize the UIView to the smallest possible that contains CGPath. In my UIView subclass, I overridden sizeThatFits to return the minimum size as such:
- (CGSize) sizeThatFits:(CGSize)size { CGRect box = CGPathGetBoundingBox(sigPath); return box.size; }
This works as expected, and the UIView will be changed to the return value, but CGPath will also be βchangedβ proportionally, which will lead to another path that was originally made by the user. As an example, this is a view showing the path drawn by the user:

And this is the outline view after resizing:

How to resize UIView instead of resizing path?
source share