Can any one please explain what is use of CGRectZero

前端 未结 5 1643
南方客
南方客 2021-01-04 05:45

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

相关标签:
5条回答
  • 2021-01-04 05:48

    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

    0 讨论(0)
  • 2021-01-04 06:03

    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);
    
    0 讨论(0)
  • 2021-01-04 06:06

    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

    0 讨论(0)
  • 2021-01-04 06:06

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

    0 讨论(0)
  • 2021-01-04 06:08
    CGRectZero = CGRectMake(0, 0, 0, 0);
    
    0 讨论(0)
提交回复
热议问题