1

我在导航控制器中有一个视图,并想创建一个“全(应用程序)屏幕”覆盖,说明用户应该做什么。我已经在其他应用程序上看到了一些透明度,并且效果很好。我正在尝试以下内容,但内容最终位于我的导航控制器标题下方。调查谈论将矩形转换为“窗口级别”位置等,但它仍然在下面。

下面我微弱的尝试有什么替代方法吗?或者一个样本的链接也会很棒。

谢谢!

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
        );

    }

(视图只是一个 UIView,它重载了将文本等放入视图的 Draw() 方法)

4

1 回答 1

1

您可以将 _overlayView 添加到视图层次结构中更高的位置,例如 NavigationViewController。如果您的 NavigationViewController 设置为您的 RootViewController(好吧,不管它是什么),您可以试试这个。

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

您也可以像这样将子视图放在前面,但这只是在该视图的前面,而不是在所有内容的前面(这不是您真正想要的,除非 _childView 是您的 NavigationViewController)。

_childView.BringSubviewToFront(_overlayView);
于 2012-12-21T06:56:08.343 回答