在 Xamarin iOS 设计器中的视图周围创建边框



是否有等效于 Xcode Storyboard> Identity Inspector>用户定义的运行时属性> 'layer.borderWidth' ?

我不记得曾经在Xamarin iOS设计器中看到过定义边框宽度或颜色的东西。我想你将不得不使用它。View.Layer.BorderWidth in your UIViewController.

在 Xamarin Studio 中,右键单击 Main.storyboard> Open With> Xcode Interface Builder。

定义运行时属性。

使用 View.Layers 添加边框颜色和宽度。 由于只有我的某些视图具有边框,因此我创建了一个视图覆盖并调用它并传递参数。

   public BorderedView(System.Drawing.RectangleF frame, UIColor borderColor, 
  UIViewController vw) : base(frame)
    {
        this.parent = vw;
        _bordercolor = borderColor;
        this.Layer.BorderWidth = 12f;
        this.Layer.Frame = new CGRect(0f, -10f, Frame.Width, Frame.Height + 
  10);
        this.CreateBorder();
        this.UserInteractionEnabled = true;
        this.ClipsToBounds = true;
        this.Add(new CircitCustomNavBar().CustomNavMenuView(borderColor, 
  this.parent));
    }
    private void CreateBorder()
    {
        // MasksToBounds == false allows the shadow to appear outside the 
  UIView frame
        this.Layer.MasksToBounds = false;
        this.Layer.CornerRadius = 0;
        this.Layer.ShadowColor = UIColor.DarkGray.CGColor;
        this.Layer.ShadowOpacity = 1.0f;
        this.Layer.ShadowRadius = 6.0f;
        this.Layer.ShadowOffset = new System.Drawing.SizeF(0f, 3f);
        this.Layer.BorderColor = _bordercolor.CGColor;

    }

最新更新