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

后端 未结 11 2482
温柔的废话
温柔的废话 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:22

    Bounds - x:0, y:0, width: 20, height: 40 is a static
    Frame - x:60, y:20, width: 45, height: 45 is a dynamic based on inner bounds.

    One more illustration to show a difference between frame and bounds. At this example:

    • View B is a subview of View A
    • View B was moved to x:60, y: 20
    • View B was rotated 45 degrees

提交回复
热议问题