Thursday, August 25, 2011

CGRect intersects another CGRect



















If we have 2 rectangles and we want to find out if they intersect, then we can do with following code:

       CGRect b=CGRectMake(40, 50, 280, 200);
    CGRect c=CGRectMake(100, 125, 80, 275);
        
   
    BOOL contains=CGRectIntersectsRect(b, c);
    
    if(contains) NSLog(@"yes"); else NSLog(@"no");
    //This will print yes because b overlaps rect c and viceversa
    
    
  


If this is not what you were looking for CGRect, try this comprehensive LIST.



No comments:

Post a Comment