我已經覆蓋OnElementChanged定製EntryRenderer它看起來像這裏面的方法:獲取CustomRenderer(Xamarin.Forms的iOS)控件的尺寸
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
var iconLabel = new UILabel();
iconLabel.Font = FontAwesome.Font(12);
iconLabel.Text = " " + FontAwesome.FAPlay;
iconLabel.Frame = new CGRect(x: 5, y: 0, width: 20, height: 20);
Control.LeftView = iconLabel;
Control.LeftViewMode = UITextFieldViewMode.Always;
Control.BorderStyle = UITextBorderStyle.None;
var bottomLine = new CALayer();
bottomLine.Frame = new CGRect(0.0, Control.Frame.Height - 1, Control.Frame.Width, 1.0);
bottomLine.BackgroundColor = UIColor.White.CGColor;
Control.Layer.AddSublayer(bottomLine);
}
}
所有我想要做的是自定義輸入控件上添加FontAwesome圖標左邊並在底部添加一層,使其看起來像只有底部邊框。
問題是Control.Frame
沒有Width
& Height
(它們的值是0)。
任何幫助或其他方式來破解邊界底部條目(UITextField)樣式? 在此先感謝。
也許你也可以檢查'e.NewElement'(這是Xamarin'Entry')不null並應用這些維度? –
@GeraldVersluis試過,沒有奏效。 –