Can any one please explain what is use of CGRectZero

老子叫甜甜 提交于 2019-11-30 01:29:46

问题


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


回答1:


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);



回答2:


CGRectZero = CGRectMake(0, 0, 0, 0);



回答3:


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




回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/22217964/can-any-one-please-explain-what-is-use-of-cgrectzero

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!