I have view that has a webview and a UIToolbar.
I want to create an animation that performs a “kCATransitionFromTop” transition by first remove the the previous webview, and then add a new webView to the superView.
During this transition, I want the toolbar to stay whatever the position it is at right now and NOT move.
Code:
Add the toolbar
toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleDefault;
toolbar.tintColor = [UIColor blackColor];
[toolbar setFrame:CGRectMake(0, 480 - 88 - 20, 320.0, 44)];
//Add the toolbar as a subview to the navigation controller.
[self.view addSubview:toolbar];
Animation:
UIView *currentView = webView;
UIView *theWindow = [currentView superview];
UIView *newView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0, 320, self.view.bounds.size.height - self.navigationController.toolbar.frame.size.height)];
newView.backgroundColor = [UIColor whiteColor];
// remove the current view and replace with new view
[currentView removeFromSuperview];
[theWindow insertSubview:newView belowSubview:toolbar];
// set up the animation
CATransition *animation = [CATransition animation];
[animation setDuration:0.4];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromTop];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"PushNextArticleView"];
Everything seems to work out ok, except the toolbar is moving with the webview as well…
What did I do wrong and how can I solve this issue?
Don’t you mean to only apply the transition to the
layerofnewView?