2

是否可以访问部分页眉和页脚的字体和颜色属性,或者我是否需要子类化 Section?我将 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)
    }
}
4

2 回答 2

12

部分页眉和页脚可以指定为字符串或 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) {
    ...
 }
于 2011-04-08T14:19:56.100 回答
1

使用米格尔的回答,我能够得到我需要的东西:

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;
}
于 2011-04-11T22:46:30.347 回答