我认为它有一个webview和一个UIToolbar。
我想创建一个执行“kCATransitionFromTop”转换的动画,首先删除以前的webview,然后将新的webView添加到superView。 在此过渡期间,我希望工具栏能够保持现在的位置,而不是移动。
代码: 添加工具栏
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];
动画:
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"];
一切似乎都没问题,除了工具栏随着webview一起移动...... 我做错了什么,我该如何解决这个问题?
答案 0 :(得分:0)
您不是要仅将转换应用于layer
的{{1}}吗?
newView