3
我想在之間的UITabBarItem
之間添加白線分隔符。 我該如何做到這一點?如何將分隔符添加到UITabbar ios
我在下面的鏈接找到在同Objective-C代碼:Add separator between section in TabBar
我想要的C#相當於相同的。
我想在之間的UITabBarItem
之間添加白線分隔符。 我該如何做到這一點?如何將分隔符添加到UITabbar ios
我在下面的鏈接找到在同Objective-C代碼:Add separator between section in TabBar
我想要的C#相當於相同的。
只需調用viewDidLoad
這個方法,你必須初始化UITabBar
private void setuptabseparator()
{
float itemWidth = (float)Math.Floor(this.TabBar.Frame.Size.Width/this.TabBar.Items.Length);
UIView bgView = new UIView(new CGRect(5, 0, this.TabBar.Frame.Size.Width, this.TabBar.Frame.Size.Height - 5));
for (int i = 0; i < this.TabBar.Items.Length - 1; i++)
{
float SEPARATOR_WIDTH = 0.8f;
UIView separator = new UIView(new CGRect((itemWidth * (i + 1) - SEPARATOR_WIDTH), 0, SEPARATOR_WIDTH, this.TabBar.Frame.Size.Height));
separator.BackgroundColor = UIColor.White;
bgView.AddSubview(separator);
}
UIGraphics.BeginImageContext(bgView.Bounds.Size);
CGContext context = UIGraphics.GetCurrentContext();
bgView.Layer.RenderInContext(context);
UIImage tabbarbackground = UIGraphics.GetImageFromCurrentImageContext();
this.TabBar.BackgroundImage = tabbarbackground;
}