UITextView - 设置边框颜色

Ian*_*ink 1 c# iphone mono xamarin.ios ios

在MonoTouch中,我尝试设置边框颜色,但由于其保护级别而无法更改BorderColor,因此无法更改.

public class BorderedUITextView:UITextView
{
    public BorderedUITextView (RectangleF Frame):base(Frame)
    {
        this.Layer.BorderColor (UIColor.Black);  ????????????
        this.Layer.BorderWidth = 1.3f;
        this.Layer.CornerRadius = 15f;
        this.ClipsToBounds = true;
    }
}
Run Code Online (Sandbox Code Playgroud)

Har*_*ban 9

你也可以从UiColor获得CGColor

this.Layer.BorderColor  = UIColor.Black.CGColor;
Run Code Online (Sandbox Code Playgroud)


pou*_*pou 6

Layer(如果a CoreAnimation.CALayer)BorderColor是属性(不是方法),它应该被指定为:

this.Layer.BorderColor = x;
Run Code Online (Sandbox Code Playgroud)

CGColor也不是UIColor

this.Layer.BorderColor = new MonoTouch.CoreGraphics.CGColor (0.5f, 0.5f);
Run Code Online (Sandbox Code Playgroud)