Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Navbar fontFamily

Hi all
is there a way to set a font family for the nav bar? I mean, i need to use a Trebuchet for titles on the bar. I've tried to do this using setTitleControl but doesn't work.
http://pastie.org/892309
BTW, how titleControl works? Could be a way?

Thanks!

— asked March 28th 2010 by Dario Meneghel
  • fontfamily
  • navbar
0 Comments

2 Answers

  • Accepted Answer

    Hmm… I've looked at your code.

    I wonder if one of these tricks might work:

    var trebuchetTitle = Ti.UI.createLabel({ ... });
    
    var imageView = Ti.UI.createImageView({
        image:trebuchetTitle.toImage()
    });
    
    win.titleControl = imageView;
    

    Or:

    var trebuchetTitle = Ti.UI.createLabel({ ... });
    
    var f = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, 'title.png');
    f.write(trebuchetTitle.toImage());
    
    win.titleImage = f.nativePath;
    

    Or:

    var button = Ti.UI.createButton({
        enabled:false,
        style:Ti.UI.iPhone.SystemButtonStyle.PLAIN,
        title:'My Title',
        height:'auto',
        width:'auto',
        color:'#000',
        font:{fontFamily:'Trebuchet MS', fontSize:22}
    });
    
    win.titleControl = button;
    
    — answered March 28th 2010 by James K
    permalink
    0 Comments
  • HI James
    thanks for your prompt reply.
    I've tried all your solutions but just the win.titleImage = f.nativePath; is quite working. I mean, it actually creates an image in Trebuchet but it's not well rendered.
    Maybe it's not a Titanium lack of API to do that, maybe it's just that it can't be done. I'm investigating how extensively fontFamily can be used to alter text elements inside an app but I understand you can work just on a label/button base. You can't for ex. set a fontFamily to a whole win.

    d

    — answered March 29th 2010 by Dario Meneghel
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.