Search code examples
titaniumtitanium-mobile

Multiline window title in titanium


I am feverishly trying to make the title of a window multiline. I have a fairly long title and need to be able to see the whole title.

Right now the title just gets cut of and has three dots if it is longer than the window allows But I need it to break into two lines if it is too long

My current markup looks like:

/////// create first starting window ////////
var startWin = Titanium.UI.createWindow({
    title: 'Some really long title that has to be wrapped',
    navBarHidden: false,
    exitOnClose: true,
    barImage: '/images/header_background.png',
    titleAttributes: {
        color: '#FFF',
        font: {
            fontSize: 20,
            minFontSize: 15,
            fontWeight: 'bold',
            wordWrap: true
        }
    }
});

Or can I maybe use a multiline label?

Anyone an idea ?

Thanx

My working code thanx to Sebastian

page_title = Ti.UI.createLabel({
    text: 'Algorithmen',
    height: 80,
    left: 60,
    right: 60,
    textAlign: 'center',
    color: '#fff',
    font: {
        fontSize: 18,
        fontWeight: 'bold',
        wordWrap: true
    }
}),
startWin = Titanium.UI.createWindow({
    titleControl: page_title,
    navBarHidden: false,
    exitOnClose: true,
    barImage: '/images/header_background.png'
});

Solution

  • You can set the window.titleControl with a label

    var startWin = Titanium.UI.createWindow({
      titleControl: Ti.UI.createLabel({
        text:'Some really long title that has to be wrapped'
        font:{
            fontSize: 20,
            minFontSize: 15,
            fontWeight: 'bold'
        }
      }),
      navBarHidden: false,
      exitOnClose: true,
      barImage: '/images/header_background.png',
    });