Sobes.tech
Junior

What is the difference between frame and bounds in iOS?

sobes.tech AI

Answer from AI

In iOS, UIView has two important properties for working with coordinates — frame and bounds.

  • frame is a rectangle describing the view's position and size in the superview's coordinate system. frame.origin is the position in the parent coordinate space.

  • bounds is a rectangle describing the view's internal coordinate system. Usually, bounds.origin is (0,0), and its size matches frame.size. bounds defines how the content is laid out inside the view.

Example: If a UIView has a frame with origin (50, 100) and size (200, 100), it is positioned 50 points from the left and 100 points from the top of its parent. Its bounds typically has origin (0,0) and size (200, 100), representing its internal coordinate system.

Thus:

  • frame is the position and size relative to the parent.
  • bounds is the internal coordinate system and size.

In Kazakh:

  • frame — ата-анасына қатысты орналасуы мен өлшемі.
  • bounds — ішкі координаттар мен өлшемі.
What is the difference between frame and bounds in… - sobes.tech