【问题标题】:set Height Entry rendered xamarin forms ios设置高度条目呈现的xamarin表单ios
【发布时间】:2017-03-24 03:10:26
【问题描述】:

我需要修改和自定义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 ???
            }
        }
    }
}

【问题讨论】:

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


    【解决方案1】:

    跨平台的 Entry 类上有一个 HeightRequest 属性。为什么不在那里设置它并让 Xamarin 的渲染器完成工作?

    如果你想直接在自己的渲染器中设置试试

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

    【讨论】:

    • 需要详细说明吗?
    【解决方案2】:

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

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

    【讨论】:

    • MyEntry 从 ios 渲染中获取没有 HeightRequest 属性的属性
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-30
    • 1970-01-01
    • 2019-07-04
    • 1970-01-01
    相关资源
    最近更新 更多