Cocoa: What's the difference between the frame and the bounds?

后端 未结 11 2459
温柔的废话
温柔的废话 2020-11-22 08:00

UIView and its subclasses all have the properties frame and bounds. What\'s the difference?

11条回答
  •  我寻月下人不归
    2020-11-22 08:15

    Let me add my 5 cents.

    Frame is used by the view's parent view to place it inside the parent view.

    Bounds is used by the view itself to place it's own content (like a scroll view does while scrolling). See also clipsToBounds. Bounds also can be used to zoom in/out content of the view.

    Analogy:
    Frame ~ TV screen
    Bounds ~ Camera (zoom, move, rotate)

提交回复
热议问题