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

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

    All answers above are correct and this is my take on this:

    To differentiate between frame and bounds CONCEPTS developer should read:

    1. relative to the superview (one parent view) it is contained within = FRAME
    2. relative to its own coordinate system, determines its subview location = BOUNDS

    "bounds" is confusing because it gives the impression that the coordinates are the position of the view for which it is set. But these are in relations and adjusted according to the frame constants.

提交回复
热议问题