Ame*_*ant 3 c# xamarin.ios ios
我想补充之间的白线分隔UITabBarItem上UITabBar.我该怎么做到这一点?
我在以下链接中找到了相同的Objective-C代码:在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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
188 次 |
| 最近记录: |