Xamarin.Forms PageRenderer 中的 UINavigationBar
Xamarin.Forms UINavigationBar in PageRenderer
我有一个相机页面渲染器,我想将底部菜单放在本机而非 Xamarin.Forms 页面的渲染器页面上。我怎样才能做到这一点?
在PageRenderer中调整View
和NavigationBar
的Frame
为名为 CustomPageRender 的页面创建自定义呈现器。
[assembly: ExportRenderer(typeof(Page), typeof(CustomPageRender))]
namespace FormsApp2.iOS
{
class CustomPageRender :PageRenderer
{
public override void ViewWillLayoutSubviews()
{
base.ViewWillLayoutSubviews();
if (this.NavigationController != null)
{
CGRect rect = View.Frame;
rect.Y = -44;
View.Frame = rect;
CGRect NavRect = NavigationController.NavigationBar.Frame;
NavRect.Y = UIScreen.MainScreen.Bounds.Height - 44;
NavigationController.NavigationBar.Frame = NavRect;
}
}
}
}
我有一个相机页面渲染器,我想将底部菜单放在本机而非 Xamarin.Forms 页面的渲染器页面上。我怎样才能做到这一点?
在PageRenderer中调整View
和NavigationBar
的Frame
为名为 CustomPageRender 的页面创建自定义呈现器。
[assembly: ExportRenderer(typeof(Page), typeof(CustomPageRender))]
namespace FormsApp2.iOS
{
class CustomPageRender :PageRenderer
{
public override void ViewWillLayoutSubviews()
{
base.ViewWillLayoutSubviews();
if (this.NavigationController != null)
{
CGRect rect = View.Frame;
rect.Y = -44;
View.Frame = rect;
CGRect NavRect = NavigationController.NavigationBar.Frame;
NavRect.Y = UIScreen.MainScreen.Bounds.Height - 44;
NavigationController.NavigationBar.Frame = NavRect;
}
}
}
}