14

I am new to iOS. Can any one please explain what the use is of CGRectZero and where it is used?

SQB
  • 3,926
  • 2
  • 28
  • 49
Siva
  • 181
  • 1
  • 1
  • 6
  • This is an example of how it can be used : http://stackoverflow.com/questions/13905144/using-autoresizingmask-with-cgrectzero – The Tom Mar 06 '14 at 07:41

5 Answers5

18

CGRectZero equals to CGRectMake(0,0,0,0). Usually it's used to fast-initialize CGRect object.

For example:

CGRect frame = CGRectZero;
frame.size.width = someWidth;
frame.size.height = someHeight;
myView.frame = frame;

From Apple's doc:

/* The "zero" rectangle -- equivalent to CGRectMake(0, 0, 0, 0). */ 

CG_EXTERN const CGRect CGRectZero
  CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
arturdev
  • 10,884
  • 2
  • 39
  • 67
2
CGRectZero = CGRectMake(0, 0, 0, 0);
Rajesh
  • 10,318
  • 16
  • 44
  • 64
2

CGRectZero

A rectangle constant with location (0,0), and width and height of 0. The zero rectangle is equivalent to CGRectMake(0,0,0,0).

Available in OS X v10.0 and later.

Declared in CGGeometry.h.

more details Geometric Zeros

codercat
  • 22,873
  • 9
  • 61
  • 85
1

The use of CGRectZero is to create and initialize a CGRect at (0,0,0,0)

KmoSkillz
  • 169
  • 1
  • 9
0

Swift 4.0 -

A rectangle constant with location (0,0), and width and height of 0. The zero rectangle is equivalent to CGRectMake(0,0,0,0).

CGRect.zero  == CGRect(x: 0, y: 0, width: 0, height: 0)

Doc

Jack
  • 13,571
  • 6
  • 76
  • 98