Predict the output
What does this print (rounded)?
let v = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
v.transform = CGAffineTransform(rotationAngle: .pi / 2)
print(v.bounds.width, v.frame.width)Hint 1 of 1
Which one is in the superview's coordinates?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: B 100 50
Correct. bounds keeps the view's own size; the rotated bounding box is 50 wide.
Why not the others?
- A 100 100. frame is the bounding box after rotation, so its width changes.
- C 50 50. Transforms don't change bounds.
- D 50 100. That swaps which one changes.