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.


  1. Nice post! Can’t wait for the next one. Keep stuff like this coming.
    Asus Laptops

  2. Thanks your blog is awesome.
    Videocon plan
    Videocon Telecom, the next-generation GSM mobile service network is the telecom arm of the $10 billion Videocon Group. The company has partnered with global technology leaders to create a robust infrastructure featuring future ready mobile technologies. Powered by the most advanced GSM-EDGE network, Videocon Telecom aims to redefine the Indian mobile telecommunications industry by leveraging a combination of the parent company’s strong brand recall and retail reach with a spirit of innovation and customer centricity. Videocon endeavours to transform the life of every Indian consumer by changing the very paradigm of the way he or she communicates.