you can check that with touchesBegan
method like bellow...
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
[touch locationInView:self.view];
if([touch.view isKindOfClass:[UIImageView class]])
{
///This is UIImageView
}
else if([touch.view isKindOfClass:[UIView class]])
{
///This is UIView
}
}
and when you move the UIImageView
at that time its change the backGroundColor of UIView
with bellow code...
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *tap = [touches anyObject];
CGPoint pointToMove = [tap locationInView:self.view];
if([tap.view isKindOfClass:[UIImageView class]])
{
UIImageView *tempImage=(UIImageView *) tap.view;
if ([yourView pointInside:pointToMove withEvent:event])
{
[yourView setBackgroundColor:[UIColor redColor]];
}
else{
[yourView setBackgroundColor:[UIColor clearColor]];//set backcolor which you want when `UIImageView` move outside of yourView
}
}
}
Also For Moving see the answer from this link Move UIImage only inside of another UIImage