我想將UINavigationBar拖到屏幕上,當出現模態UIView時,就像它在Reeder中一樣。動畫U導航欄離屏離開黑色矩形
我使用的是優秀的SVWebViewController(https://github.com/samvermette/SVWebViewController)來處理從shouldStartLoadWithRequest
動畫代碼是創建一個Web瀏覽器從http://www.theappcodeblog.com/2011/06/02/iphone-app-animation-tutorial-animate-a-uiview-frame/
一切正常在導航欄中放置在屏幕之外,但留下的空間(我想將它放入其中)是BLACK。視圖/ 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;
}
TIA
通過設置uiwebview掩碼?如果是的話,什麼是設置請(我是一個xib迷!) – JulianB 2012-03-10 18:39:55
沒有辦法用xibs ... – 2012-03-11 14:29:06
我沒有使用xib ...這裏的init代碼 - (void)loadView { mainWebView = [ [UIWebView alloc] initWithFrame:[UIScreen mainScreen] .applicationFrame]; [mainWebView setBackgroundColor:[UIColor greenColor]]; mainWebView.delegate = self; mainWebView.scalesPageToFit = YES; [mainWebView loadRequest:[NSURLRequest requestWithURL:self.URL]]; self.view = mainWebView; } – JulianB 2012-03-11 16:55:02