2012-12-20 59 views
1

我有一個導航控制器內的視圖,並希望創建一個'完整(應用程序)屏幕'覆蓋,說什麼用戶應該做的事情。我已經在其他應用程序上看到了一些透明度,並且效果很好。我正在嘗試下面,但內容結束了我的navcontroller標題下。調查討論將矩形轉換爲「窗口級」位置等,但仍然在下面。IOS:創建全屏'覆蓋'UIView(Monotouch)

下面我的微弱嘗試的任何替代品?或者一個樣本的鏈接也會很好。

謝謝!

HelpOverlayUIView _overlayView; 

    public void PresentHelpOverlay() 
    { 
     RectangleF windowFullFrame = new RectangleF(0,0,UIScreen.MainScreen.Bounds.Width,UIScreen.MainScreen.Bounds.Height); 

     // Conversion? 
     //[aView convertPoint:localPosition toView:nil]; 
     RectangleF overlayFrame = View.ConvertRectFromView(windowFullFrame ,null); 

     // Clear old one if it exists. 
     if (_overlayView != null) _overlayView = null; 

     // Instantiate popup view and add to (in this case the 2nd tier view). This is in an abstract class, if in a concrete one it'd normally just be View.Add 
     _overlayView = new HelpOverlayUIView(this, overlayFrame); 

     // tried th, didn't change it. 
     // this.WantsFullScreenLayout = true; 
     // _childView.BringSubviewToFront(_overlayView); 
     _overlayView.Alpha = 0; 

     _childView.Add (_overlayView); 

     // Setup event to close without doing anything. 
     _overlayView.CloseView += (sender, e) => { 

      Console.WriteLine ("close called"); 
      // animate modal popup's departure 
      UIView.Animate (
       0.5f, 
       () => { 
       // Anim Code 
       _overlayView.Alpha = 0; 
      }, 
      null 
      ); 

     }; 

     // animate modal popup's arrival 
     UIView.Animate (
      0.5f, 
      () => { 
      // Anim Code 
      _overlayView.Alpha = 1; 
     }, 
     null 
     ); 

    } 

(該視圖僅僅是一個過載到Draw()方法的UIView是放置文本等輸入到視圖)

回答

1

你可以在視圖層次結構的_overlayView添加的東西越往上如NavigationViewController。如果你的NavigationViewController被設置爲你的RootViewController(不管什麼是真的),你可以試試這個。

((AppDelegate)UIApplication.SharedApplication.Delegate).Window.RootViewController.Add(_overlayView); 

你也可以把一個子視圖像這樣前面,但這只是該視圖的前面,而不是眼前的一切(這是不是真的,你想要的東西,除非_childView是你NavigationViewController )。

_childView.BringSubviewToFront(_overlayView); 
+1

謝謝,我會給它一個去! – Glinkot

+0

我在這個很多個月之後再添加一點。確保上面的'窗口'是小寫'w'。確實有一個W大寫的窗口,但在我的情況下,它拋出了一個異常。 – Glinkot