我想在模式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
答案 0 :(得分:9)
如果为UINavigationBar设置动画,更改留下区域颜色的答案是
self.navigationController.view.backgroundColor = [UIColor redColor];
答案 1 :(得分:0)
如果您想要将NavBar移动到屏幕外,此位置当前没有任何内容,这就是它为黑色的原因。
你应该尝试通过调整它的框架属性来扩大WebView以填充NavBar之前所覆盖的空间。
答案 2 :(得分:0)
在Controller和Web View的nib文件中,在Web View上设置自动调整大小屏幕以自动调整高度和宽度。然后它会工作。