UIView bounds and transformsBasics article available: Layout Anchors
A really interesting side-effect of a
bounds being its rect within its own coordinate system is that transforms don't affect it at all. That's why it's usually a better fit than
frame when doing layout calculations of subviews.
let view = UIView() view.frame.size = CGSize(width: 100, height: 100) view.transform = CGAffineTransform(scaleX: 2, y: 2) print(view.frame) // (-50.0, -50.0, 200.0, 200.0) print(view.bounds) // (0.0, 0.0, 100.0, 100.0)
Support Swift by Sundell by checking out this sponsor:
Essential Developer: Learn the most up-to-date techniques and strategies for testing new and legacy Swift code in this free practical course for developers who want to become complete senior iOS developers. This virtual event includes lectures, mentoring sessions, and step-by-step instructions. Click to learn more.