5

From the Apple Documentation, the maxY of a view is

The largest value for the y-coordinate of the rectangle.

The maxX of a view is

The largest value of the x-coordinate for the rectangle.

Also from the Apple Documentation, the width of a view is

The width of the specified rectangle.

The height of a view is

The height of the specified rectangle.

If the view being specified took up the whole screen, then what would be the difference between these properties, and when should I use each?

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

18

They are the same when the origin is 0,0 but quite different otherwise.

Imagine the CGRect with x: 10, y: 30, width: 15, height: 40

Obviously width is 15 and height is 40. But maxX is 25 and maxY is 70.

Basically, maxX is origin.x + width and maxY is origin.y + height.

The above assumes a "normal" rectangle with a positive width and height. When you have a negative width or height, the calculation for maxX or maxY are a little different.

rmaddy
  • 314,917
  • 42
  • 532
  • 579