【问题标题】:Monotouch.Dialog : Section fontMonotouch.Dialog : 部分字体
【发布时间】:2011-08-01 04:50:29
【问题描述】:

是否可以访问部分页眉和页脚的字体和颜色属性,或者我需要子类化部分吗?我将 UI 更改为全黑,除了部分页眉和页脚外,一切看起来都很棒。

反射 API:

class Login
{
    public string Version = "1.2.3";

    [Section ("Enter your credentials", "Email and password are required")]

    [Entry ("Enter your email address")]
    public string email;

    [Caption ("Password"), Password ("Enter your password")]
    public string password;

    [OnTap ("Login")]
    [Alignment (UITextAlignment.Center)]
    public string Logon;
}

元素 API:

return new RootElement ("Login") {
    new Section() {
        new StringElement ("Version", "1.2.3")
    },
    new Section ("Enter your credentials", "Email and password are required") {
        new EntryElement("Email", "Enter your email address", "azcoov"),
        new EntryElement("Password", "Enter your password", "password", true),
        new StringElement("Logon", Login)
    }
}

【问题讨论】:

    标签: xamarin.ios monotouch.dialog


    【解决方案1】:

    部分页眉和页脚可以指定为字符串或 UIViews,遗憾的是,两者之间没有任何内容。

    如果您想要自定义标题/视图,您需要创建一个 UILabel 并在您的构造函数中将其用于 Section 类型(仅适用于 Elements API)。

    类似:

    var header = new UILabel (new RectangleF (0, 0, 320, 48)){
        Font = UIFont.BoldSystemFontOfSize (22),
        BackgroundColor = UIColor.Red
    }
    
    new Section(header, footer) {
        ...
     }
    

    【讨论】:

      【解决方案2】:

      使用 Miguel 的回答,我得到了我需要的东西:

      RootElement CreateRoot (String lat, String lng)
      {
          var header = new UILabel (new RectangleF (0, 0, 320, 48)) {
              Font = UIFont.BoldSystemFontOfSize (22),
              BackgroundColor = UIColor.Black,
              TextColor = UIColor.White,
              Text = "This is my header"
          };
          var footer = new UILabel (new RectangleF (0, 0, 320, 48)) {
              Font = UIFont.BoldSystemFontOfSize (22),
              BackgroundColor = UIColor.Black,
              TextColor = UIColor.White,
              Text = "This is my footer"
          };
      
          var rootElement = new RootElement ("Location Example"){
              new Section (header, footer){
                  new StyledStringElement("Latitude", lat),
                  new StyledStringElement ("Longitude", lng)
              },
              new Section() {
                  new StringElement ("Get location", GetLocation),
                  new StringElement ("Clear location", ClearLocation),
                  new StringElement ("Show on Map", ShowOnMap)
              }
          };
          return rootElement;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-15
        • 1970-01-01
        • 1970-01-01
        • 2012-03-07
        相关资源
        最近更新 更多