CGRectIntegral what is the usage of it?

前端 未结 3 1083
小蘑菇
小蘑菇 2020-12-08 04:20

How does one use the CGRectIntegral function? I understand it\'s purpose.

The documentation isn\'t clear on it\'s exact use.

3条回答
  •  鱼传尺愫
    2020-12-08 05:26

    CGRectIntegral Method is used to create integer rect . I mean to say suppose if you calculate frame in app you may get frames value in float.

    Setting float value as frame to some UIElement like UILabel would make the text looks blur. To avoid that, we use CGRectIntegral.Please look at the example below,

    NSLog(@"%@",NSStringFromCGRect(   CGRectIntegral(CGRectMake(0, 15.6, 16.1, 20.2))));
    

    This will print, {0,15},{17,21}.

    This explanation is found in the header file.

    /* Expand `rect' to the smallest rect containing it with integral origin and
       size. */
    

提交回复
热议问题