【发布时间】:2020-06-16 11:23:01
【问题描述】:
我在 Xamarin Forms 中创建了一个自定义视图渲染器,并且想知道视图的大小,以便我可以添加具有绝对定位的子视图。
protected override void OnElementChanged(ElementChangedEventArgs<MyView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
if (Control == null)
{
var uiView = new UIView
{
BackgroundColor = UIColor.SystemPinkColor
};
SetNativeControl(uiView);
// How to get uiView width and height in absolute numbers?
}
}
}
当我检查 uiView.Frame 时,宽度和高度都为 0。
在 PCL 中,MyView 显示为 Grid 元素的子元素。
【问题讨论】:
标签: xamarin xamarin.forms uiview xamarin.ios