【问题标题】:How to align right, sections of a rootElement in a DialogViewController如何在 DialogViewController 中右对齐 rootElement 的部分
【发布时间】:2014-04-07 13:35:20
【问题描述】:

我正在 Xamarin Studio 中使用 c# 为 iOS 编写一些代码。在 dialogViewController 中,我正在创建一个具有多个 Sections 的 rootElement。我如何对齐 Section 的 Right 、Caption 和 Elements 。我正在像这样创建 rootElement:

 RootElement  CreateRootElement ()
{       
  return new RootElement ("RootElement") 
  {
  new Section ("Caption1") {
    (createFirstElement ())
    },
  new Section ("Caption2")) {
    (createSecondElement ())
    }
  };
}

List<Element> createFirstElement ()
{
 List<Element> myList;
 //fill this list
 return myList;
}

【问题讨论】:

    标签: c# ios xamarin.ios xamarin monotouch.dialog


    【解决方案1】:

    您可以通过以下方法使用 Section 初始化程序“public Section(UIView header)”来创建右对齐的部分标题:

    private UILabel LabelForSection(string title) {
        RectangleF frame = new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width, 22);
        UILabel label = new UILabel(frame);
        label.TextAlignment = UITextAlignment.Right;
        label.Text = "Caption1";
        return label;
    }
    

    然后像这样初始化你的部分:

    new Section(LabelForSection("Caption1"))
    

    你能举例说明你所说的意思吗:

    如何对齐节的右元素?

    【讨论】:

      猜你喜欢
      • 2021-05-08
      • 2012-11-26
      • 2019-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-06
      • 1970-01-01
      相关资源
      最近更新 更多