开发者

Monotouch.Dialog : Section font

开发者 https://www.devze.com 2023-02-23 02:59 出处:网络
It it possible to access the font and color properties of the section header and footer or do I need to subclass Section? I changed my UI to all black and everything looks great except my section head

It it possible to access the font and color properties of the section header and footer or do I need to subclass Section? I changed my UI to all black and everything looks great except my section headers and footers.

Reflection 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"), Passw开发者_C百科ord ("Enter your password")]
    public string password;

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

Element 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)
    }
}


Section headers and footers can either be specified as strings or UIViews, there is sadly, nothing in between.

If you want to have custom headers/views, you would need to create a UILabel and use that in your constructor to the Section type (only available for the Elements API).

Something like:

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

new Section(header, footer) {
    ...
 }


Using Miguel's answer I was able to get what I needed:

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消