Search code examples
framecgrect

No member named 'frame' in struct CGRect


I get the error "No member named 'frame' in struct CGRect".

    UITouch *touch = [[event2 allTouches] anyObject];
CGPoint touchlocation = [touch locationInView:self.view];
if ( CGRectContainsPoint( enemy.frame, touchlocation ) ) {
    MedalGo = 0;
    // inside imgView
} else {
    // outside imgView Now we will found out is it within proximityImgViewRect
    CGRect proximityImgViewRect = CGRectMake( enemy.frame.origin.x-25,enemy.frame.origin.y - 25, enemy.frame.size.width+50,enemy.frame.size.height+50);
    if ( CGRectContainsPoint( proximityImgViewRect.frame, touchlocation ) ) {
        // inside proximityImgViewRect
        MedalGo = 1;

    } else {
        //outside proximityImgViewRect
        MedalGo = 0;
    }
}

Any help would be appreciated. Thank you.


Solution

  • A CGRect is the frame.

     if ( CGRectContainsPoint( proximityImgViewRect.frame, touchlocation ) )
    

    no

     if ( CGRectContainsPoint( proximityImgViewRect, touchlocation ) )
    

    yes