Jul*_*anB 1 iphone uinavigationbar uiwebview uinavigationcontroller ios
当模态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的其余部分是WHITE.
如何将空间分配给导航栏白色,即视图的背景为白色?没有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;
}
Run Code Online (Sandbox Code Playgroud)
TIA
如果为UINavigationBar设置动画,则更改留下区域颜色的答案是
self.navigationController.view.backgroundColor = [UIColor redColor];