Subtract CGRect from CGRect — largest piece of one not containing the other

后端 未结 3 1588
不思量自难忘°
不思量自难忘° 2021-02-07 08:05

How I can substract one CGRect from another? I want the result R1 - R2 to be the largest subrectangle of R1 that does not intersect R2.

3条回答
  •  隐瞒了意图╮
    2021-02-07 08:47

    Would probably go something like this:

    CGRect frame = CGRectMake(0, 0, 320, 480);
    float aWidth  = frame.size.width; /* say for instance 320 */
    float aHeight = frame.size.height; /* say for instance 480 */
    
    int final = aWidth - aHeight;
    NSLog(@"Should be -160, your answer: %i",final);
    

提交回复
热议问题