i i在导航controller中有一个视图,并希望创建一个'完整(应用程序)屏幕'覆盖层,其中说明了用户应该做什么的几件事。我已经看到了其他应用程序对此的透明度,并且效果很好。我正在尝试下面,但内容最终位于我的NavController标题下。调查谈论将矩形转换为"窗口级别"的位置等,但仍在下面。
我在下面尝试微弱尝试的其他选择吗?否则样品的链接也很棒。
谢谢!
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()方法的过载,将文本等放入视图中)
您可以将_overlayView添加到视图层次结构中的更高内容,例如NavigationViewController。如果您的NavigationViewController设置为您的rootviewController(嗯,无论是真正的),您可以尝试。
((AppDelegate)UIApplication.SharedApplication.Delegate).Window.RootViewController.Add(_overlayView);
您还可以将一个子视图带到前线,但这仅在该视图的前面,而不是在所有事物的前面(这不是您想要的,除非_childview是您的Navigation ViewController)。
_childView.BringSubviewToFront(_overlayView);