Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can any one please explain what is use of CGRectZero

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

like image 918
Siva Avatar asked Mar 06 '14 07:03

Siva


People also ask

What is CGRect zero?

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

What is CGSize?

Overview. A CGSize structure is sometimes used to represent a distance vector, rather than a physical size. As a vector, its values can be negative. To normalize a CGRect structure so that its size is represented by positive values, call the CGRectStandardize(_:) function.

What is CGRect?

A structure that contains the location and dimensions of a rectangle.


1 Answers

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);
like image 116
arturdev Avatar answered Oct 03 '22 01:10

arturdev