Titanium Community Questions & Answer Archive

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

win.setTitleControl

Hi! I want to change the font color of the navigation tab bar text, but the text is not shown. What am I doing wrong?

tableview.addEventListener('click', function(e)
{

    if (e.rowData.url)
    {

            var win = Titanium.UI.createWindow({
        url:e.rowData.url,
                backgroundColor: e.rowData.backgroundColor,
                barColor: e.rowData.backgroundColor
            });

            var trebuchetTitle = Titanium.UI.createLabel({
                text:'My title',
                height:'auto',
                width:'auto',
                shadowColor:'#aaa',
                shadowOffset:{x:5,y:5},
                color:'#000',
                font:{fontFamily:'Trebuchet MS',fontSize:22},
                textAlign:'center'
            });

            win.setTitleControl(trebuchetTitle);
        }
}
— asked May 21st 2010 by Roxana Oprea
  • settitlecontrol
0 Comments

5 Answers

  • reading this:

    http://stackoverflow.com/questions/599405/iphone-navigation-bar-title-text-color

    It comes to my mind that you might need to reduce the font size.

    Let me know if is working :)

    — answered May 21st 2010 by Dan Tamas
    permalink
    0 Comments
  • I reduced it to 14 and still the same problem

    — answered May 21st 2010 by Roxana Oprea
    permalink
    0 Comments
  • I do this in my apps - but I have the label added to view first :

    var titleView = Ti.UI.createView({
        width:210,
        height:40
    });
    
    var titleLabel = Titanium.UI.createLabel({
        color:'#000',
        height:18,
        width:210,
        top:5,
        text:'A Trebuchet TItle',
        textAlign:'center',
        font:{fontFamily:'Trebuchet MS',fontSize:18,fontWeight:'bold'},
        shadowColor:'#eee',shadowOffset:{x:0,y:1}
    });
    titleView.add(titleLabel);
    
    win.titleControl = titleView;
    

    hope this helps ;)

    — answered May 22nd 2010 by Kosso
    permalink
    1 Comment
    • What is the advantage of putting it in a view?

      — commented February 2nd 2011 by Danny Roa
  • Hi! Thank you for your responses, but the title is not changing, only if I put the code in app.js (the main window). If I try to make a new window, through an event listener, then the title is not shown. I don't understand why?

    — answered May 25th 2010 by Roxana Oprea
    permalink
    0 Comments
  • I found the problem. My project was made with Titanium 1.2.1 version. I updated the version to 1.3 and made a new project, and now it's working. So it's a bug in 1.2.1

    — answered May 25th 2010 by Roxana Oprea
    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.