【发布时间】:2016-08-05 19:34:08
【问题描述】:
我在自定义的 EntryRenderer 中重写了 OnElementChanged 方法,如下所示:
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);
}
}
我要做的就是自定义Entry控件,在左侧添加FontAwesome图标,并在底部添加一个图层,使其看起来只有底部边框。
问题是Control.Frame 没有Width & Height(它们的值为0)。
破解边框底部条目(UITextField)样式的任何帮助或其他方法? 提前致谢。
【问题讨论】:
-
也许您还可以检查
e.NewElement(即 XamarinEntry)是否不为空并应用这些维度? -
@GeraldVersluis 试过了,没用。
标签: xamarin xamarin.ios xamarin.forms