#define LIKED 100 //change as per your requirement
#define UNLIKE 200 //change as per your requirement
- (void) likeUnlike:(UIGestureRecognizer *)sender
{
[imageViewSub setHidden:NO];
UIImageView *imageView = (UIImageView *)sender.view;
if(imageView.tag==LIKED)
{
[imageViewSub setImage:[UIImage imageNamed:@"unlike.png"]];
[imageView setTag:UNLIKE];
}
else
{
[imageViewSub setImage:[UIImage imageNamed:@"like.png"]];
[imageView setTag:LIKED];
}
//here, your like/unlike update call to server for store selection.
//set the frame exactly you want or
//implement some other way to hide `imageViewSub` after like/unlike
[imageViewSub setFrame:CGRectMake( 110, 180, 100, 100)];
[UIView beginAnimations:@"anim" context:nil];
[UIView setAnimationDuration:1.0];
[imageViewSub setFrame:CGRectMake(200, 200, 0, 0)];
[UIView commitAnimations];
}
//Add below code where you're added/showing your images. There's always two `UIImageView`s one is `main` and other one is `sub`.
[imageViewSub bringSubviewToFront:imageViewMain];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] init];
[doubleTap setNumberOfTapsRequired:2];
[doubleTap addTarget:self action:@selector(likeUnlike:)];
[imageViewMain addGestureRecognizer:doubleTap];
[doubleTap release];
P.S. imageViewMain will initially having tag from UNLIKED and imageViewSub having unlike.png and should be hidden.