【发布时间】:2012-03-12 02:13:56
【问题描述】:
当模态 UIView 出现时,我想将 UINavigationBar 显示在屏幕上,就像在 Reeder 中一样。
我正在使用出色的 SVWebViewController (https://github.com/samvermette/SVWebViewController) 来处理从 shouldStartLoadWithRequest 中创建 Web 浏览器
动画代码来自http://www.theappcodeblog.com/2011/06/02/iphone-app-animation-tutorial-animate-a-uiview-frame/
导航栏中的所有内容都放置在屏幕外,但留下的空间(我想将其动画化)是黑色的。视图/webview 的其余部分是白色的。
如何将分配给导航栏的空间设置为白色,即视图的背景为白色? 没有xib。
我在 SVWebViewController 中找不到任何提及导航栏(仅添加工具栏)
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"They clicked: %@", request);
NSURL *requestURL = [request URL];
if ([[requestURL scheme ] isEqualToString: @"http"] || [[requestURL scheme] isEqualToString: @"https"]) {
NSLog(@"Web link %@",requestURL);
SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithURL:requestURL];
webViewController.modalPresentationStyle = UIModalPresentationFullScreen;
webViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
webViewController.availableActions = SVWebViewControllerAvailableActionsOpenInSafari | SVWebViewControllerAvailableActionsCopyLink | SVWebViewControllerAvailableActionsMailLink;
// ios5
if ([[UINavigationBar class]respondsToSelector:@selector(appearance)]) {
// Create image for navigation background - portrait
UIImage *NavigationPortraitBackground = [[UIImage imageNamed:@"navbar_bg_portrait~iPad"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Create image for navigation background - landscape
UIImage *NavigationLandscapeBackground = [[UIImage imageNamed:@"navbar_bg_portrait~iPad"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Set the background image all UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:NavigationPortraitBackground forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:NavigationLandscapeBackground forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
// The tintcolor affects the button colour
UIColor* col = OPAQUE_HEXCOLOR(0xdb536a);
[[UIBarButtonItem appearance] setTintColor:col];
} else {
// Style the Nav Bar ios4
[webViewController.navigationBar applyCustomTintColor];
}
[self presentModalViewController:webViewController animated:YES];
// -> This code hides the UINavigationBar before animation
CGRect navBarFrame = webViewController.navigationBar.frame;
navBarFrame.origin.y = -navBarFrame.size.height;
// set the position of the bar
webViewController.navigationBar.frame = navBarFrame;
// <- end Hide code
return NO;
}
return YES;
}
TIA
【问题讨论】:
标签: iphone ios uiwebview uinavigationcontroller uinavigationbar