如何将UITextView的大小设置为100?

时间:2017-11-20 13:21:08

标签: xamarin xamarin.forms

我正在使用此代码创建添加到页脚的UITextView。

public override UIView GetViewForFooter(UITableView tableView, nint section)
{
    var txtView = new UITextView
    {
        Editable = false,
        Text = "Select or deselect cards from the list above and they will added or removed from the card deck,",
        TextAlignment = UITextAlignment.Justified,
        TextContainerInset = new UIEdgeInsets(top: 10, left: 15, bottom: 5, right: 5),
        BackgroundColor = Color.Transparent.ToUIColor()
    };

    txtView.TextContainer.LineBreakMode = UILineBreakMode.WordWrap;
    return txtView;
}

任何人都可以告诉我如何让这个UITextView的高度为100?

2 个答案:

答案 0 :(得分:0)

public override UIView GetViewForFooter(UITableView tableView, nint section)
{
    var txtView = new UITextView(new Rectangle(0,0,0,100))
    {
        ..........
    };

    ........
}

试试这个希望它有所帮助。

答案 1 :(得分:0)

  1. 覆盖方法GetHeightForFooter

    public override nfloat GetHeightForFooter(UITableView tableView, nint section)
    {
        return 100;
    }
    
  2. 在UITextView上设置框架

    public override UIView GetViewForFooter(UITableView tableView, nint section)
    {
        var txtView = new UITextView
        {
            Frame = new CGRect(0,0, tableView.Frame.Width,100),
            Editable = false,
            Text = "Select or deselect cards from the list above and they will added or removed from the card deck,",
            TextAlignment = UITextAlignment.Justified,
            TextContainerInset = new UIEdgeInsets(top: 10, left: 15, bottom: 5, right: 5),
            BackgroundColor = Color.Transparent.ToUIColor()
        };
    
        txtView.TextContainer.LineBreakMode = UILineBreakMode.WordWrap;
        return txtView;
    }