1

我想將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

回答

9

答案改變的區域的顏色,如果你動畫一個UINavigationBar的是留下

self.navigationController.view.backgroundColor = [的UIColor redColor];

0

如果你想離屏幕移動的NavBar,沒有什麼是目前在這個地方留下任何提及這就是爲什麼它是黑色的。
您應該嘗試放大WebView以填充NavBar先前通過調整其框架屬性覆蓋的空間。

+0

通過設置uiwebview掩碼?如果是的話,什麼是設置請(我是一個xib迷!) – JulianB 2012-03-10 18:39:55

+0

沒有辦法用xibs ... – 2012-03-11 14:29:06

+0

我沒有使用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

0

在控制器和Web視圖的nib文件中,在Web視圖上設置自動調整大小掩碼以自動調整高度和寬度。然後它會工作。

+0

正如我所提到的,這個類沒有xib – JulianB 2012-03-11 02:54:03