In this post, we will define how to put press effect on tap gesture on UIView.
Steps:
1. First of all choose the view on which you want to put button press effect.
Ex: Lets say we have a view with name tappedView
2. Change background color of the view before doing the effect of tap.
tappedView.backgroundColor = [UIColor lightGrayColor];
3. Then queue the reverse of step 2 to happen in future and after that perform what you wanted to do on tap.
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, .05 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
tappedView.backgroundColor = [UIColor whiteColor];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *nextViewController = [storyboard instantiateViewControllerWithIdentifier:@"viewControllerIdentifier"];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:nextViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
});