2011-10-12 143 views
1

在MonoTouch中,我嘗試設置邊框顏色,但由於其保護級別而無法訪問BorderColor,因此無法更改。UITextView - 設置邊框顏色

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

「邊框顏色設置如何」 - 在下面回答 –

回答

6

Layer(如果CoreAnimation.CALayerBorderColor是一個屬性(不是法)因此它應該分配這樣的:

this.Layer.BorderColor = x; 

而且它是一個CGColor不是UIColor

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

你也可以從UiColor獲得CGColor

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