如何在tabbar Xamarin表单IOS中设置边距?
我正在使用Xamarin表单并创建选项卡式页面。在IOS中,我想增加选项卡栏的高度,所以在选项卡标题的底部显示一些空间。我怎么设置这个 我尝试了以下代码,但没有成功。是否有其他方法设置底部的边距如何在tabbar Xamarin表单IOS中设置边距?,xamarin,xamarin.forms,xamarin.ios,Xamarin,Xamarin.forms,Xamarin.ios,我正在使用Xamarin表单并创建选项卡式页面。在IOS中,我想增加选项卡栏的高度,所以在选项卡标题的底部显示一些空间。我怎么设置这个 我尝试了以下代码,但没有成功。是否有其他方法设置底部的边距 public class BottomTabbedPage : TabbedRenderer { private readonly float tabBarHeight = 72f; public override void ViewWillAppear(bool animated)
public class BottomTabbedPage : TabbedRenderer
{
private readonly float tabBarHeight = 72f;
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
TabBar.UnselectedItemTintColor = UIColor.FromRGB(208,208,208);
TabBar.BackgroundColor = UIColor.White;
TabBar.Frame = new CGRect(TabBar.Frame.X, TabBar.Frame.Y + (TabBar.Frame.Height - tabBarHeight), TabBar.Frame.Width, tabBarHeight);
}
}
您应该将下面的代码放入事件
ViewWillLayoutSubviews()
:
编辑:
如果要调整图标和标题的位置,请使用以下命令:
foreach (UIViewController vc in ViewControllers)
{
//Adjust the title's position
vc.TabBarItem.TitlePositionAdjustment = new UIOffset(0, -36);
//Adjust the icon's position
vc.TabBarItem.ImageInsets = new UIEdgeInsets(-36, 0, 36, 0);
}
您应该将下面的代码放入事件
ViewWillLayoutSubviews()
:
编辑:
如果要调整图标和标题的位置,请使用以下命令:
foreach (UIViewController vc in ViewControllers)
{
//Adjust the title's position
vc.TabBarItem.TitlePositionAdjustment = new UIOffset(0, -36);
//Adjust the icon's position
vc.TabBarItem.ImageInsets = new UIEdgeInsets(-36, 0, 36, 0);
}
是的,这很好,但我想在底部添加边距,因为页面显示的标题是触摸屏显示。知道吗?@srusthakkar请检查我的更新,使用上面的代码调整。谢谢。我会检查它是的,这很好,但我想在底部添加边距,因为页面显示的标题触摸屏显示。知道吗?@srusthakkar请检查我的更新,使用上面的代码调整。谢谢。我会检查的