设置高度条目呈现xamarin形式ios

时间:2017-01-26 16:24:15

标签: ios xamarin xamarin.ios xamarin.forms controls

我需要在Xamarin中修改和自定义Entry Control,但是我很难设置,或者更确切地说是找到声明Xamarin ios控件高度的方法。 我能怎么做 ?这是我的代码。

[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace MyApplication.iOS
{
    public class MyEntryRenderer : EntryRenderer
    {
        //CUSTOM entry RENDER IOS
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.BackgroundColor = UIColor.FromRGB(43, 50, 58);
                Control.TextColor = UIColor.FromRGB(255, 255, 255);  
                //Control.Height ???
            }
        }
    }
}

2 个答案:

答案 0 :(得分:0)

跨平台的Entry类中有一个HeightRequest属性。为什么不把它放在那里让Xamarin的渲染器完成这项工作?

如果您想直接在自己的渲染器中设置,请尝试

Control.Frame = new CGRect(0, 0, width, height);

答案 1 :(得分:-1)

您可以在PCL /共享端进行设置。

public MyEntry()
{
    this.HeightRequest = 50;
}