UITextView - 设置边框颜色

时间:2011-10-12 22:04:14

标签: c# iphone ios mono xamarin.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;
    }
}

2 个答案:

答案 0 :(得分:9)

你也可以从UiColor获得CGColor

this.Layer.BorderColor  = UIColor.Black.CGColor;

答案 1 :(得分:6)

Layer(如果CoreAnimation.CALayerBorderColor是属性(不是方法),则应将其指定为:

this.Layer.BorderColor = x;

它也是CGColor而不是UIColor

this.Layer.BorderColor = new MonoTouch.CoreGraphics.CGColor (0.5f, 0.5f);