How to change frame like using CGAffineTransform?

I have WebView, which I want to change his size.
I use CGAffineTransform looks like -
Code Block
let transform: CGAffineTransform = .init(scaleX: 0.2, y: 0.2)
UIView.animate(withDuration: 0.5) {
webView.transform = transform
}


Then I get a true result - my webView's frame is changed, but content size in the webView has not changed.
When I use -

Code Block
UIView.animate(withDuration: 0.5) {
webView.frame = CGRect(...)
}

My webView's frame is changed, but content size in the webView IS CHANGED. How I can get result for changing frame like using CGAffineTransform?

Replies

Transform captures an image of the view (in fact, it layers a new image "on top" and hides the original) and makes the transformation on this new image. Hence, content is frozen during animation.

When you reset the frame, then the content may change.

Conclusion: for a simple resizing of the view, restating frame is better.
But if you wanted an animation effect as a spiralling zooming to zero size, then transform is the way to go.

Don't forget to close the thread if that's OK.