backgroundImage not working on new Window.

You must Login before you can answer or comment on any questions.

It's on iPhone. I am creating a window with this:

var w = Titanium.UI.createWindow({
        url: '/Views/WinNewProj.js',
            backgroundImage:'/Images/Background.png'
    });
 
    w.open({modal:true});
But the new window comes with a black background instead of my image.

Also, in app.js I have this:

Titanium.UI.setBackgroundImage('Images/Background.png');
And it's working, my other window has this background image.

What's wrong with the modal window?

1 Answer

Bernado, I did some tests, it seem that the modal window will show with it's background color set only if you call the open function AFTER the app creation process. Here I call it with a timeout of one second, and I got my window showing all right.

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
 
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
 
// create a window 
var window = Titanium.UI.createWindow({    
    backgroundColor:'#990'
});
 
// create a tab as default view
var myTab = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:window
});
tabGroup.addTab(myTab);  
 
 
// NOW WE CREATE THE MODAL WINDOW
var windowModal = Titanium.UI.createWindow({backgroundColor:'#FCF'});
 
// SET THE INTERVAL, THIS COULD ALSO BE A LISTENER
var int = setTimeout(function(){
 
// YOUR MODAL OPENS
windowModal.open({
    modal:true,
    modalTransitionStyle: Ti.UI.iPhone.MODAL_TRANSITION_STYLE_FLIP_HORIZONTAL,
    modalStyle: Ti.UI.iPhone.MODAL_PRESENTATION_FORMSHEET
})
},2000);
 
 
// open tab group
tabGroup.open();

Your Answer

Think you can help? Login to answer this question!