Modal Window Smaller than Full Screen
In the image example for Modal windows (here, Window API Reference) The modal window is shown smaller than the full size of the screen. No matter what, trying to recreate that doesn't seem to work. The modal window always appears as the full width and height of the available screen.
Example:
modalwindow = Ti.UI.createWindow({
width: 400,
height: 500,
top: 40,
left: 40,
borderRadius: 10,
title: 'Modal Window',
rightNavButton: cancelButton,
orientationModes: [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT]
});
modalwindow.open({
modal: true,
modalTransitionStyle: Ti.UI.iPhone.MODAL_TRANSITION_STYLE_COVER_VERTICAL,
modalStyle: Ti.UI.iPhone.MODAL_PRESENTATION_FORMSHEET
});
In this instance, it seems that the height, width, top, left, and border radius are completely ignored. The window opens with the correct transition, but fills the screen entirely instead of taking up only its defined space.
How can we accomplish making modal windows work like the example image?
6 Answers
-
I solved this by making a regular full screen transparent window, which only contains an opaque view with the desired content. This window, even if it is transparent won't allow the manipulation of the elements underneath it, so it's for all purposes a modal window.
var win = Ti.UI.createWindow({ backgroundColor : '#40000000' }); var win_height = Ti.Platform.displayCaps.platformHeight * 0.35; var win_width = Ti.Platform.displayCaps.platformWidth * .7; var view = Ti.UI.createView({ backgroundColor : 'black', borderColor : '#A5A5A5', borderRadius : 40, borderWidth : 2, width : win_width, height : win_height }); //rest of the code follows...
-
I don't have a solution for this issue (it might be a Titanium bug) but a workaround is to just open the modal window without making it a modal.
Just define it as you have above, but just call
modalWindow.open();
without any of the other modal-specific stuff. -
Set modalStyle to "Ti.UI.iPhone.MODAL_PRESENTATION_PAGESHEET" makes "width" and "height" parameter work.
myModalWin.open({ modal:true, modalTransitionStyle: Ti.UI.iPhone.MODAL_TRANSITION_STYLE_COVER_VERTICAL, modalStyle: Ti.UI.iPhone.MODAL_PRESENTATION_PAGESHEET });
-
I have the same Problem. Setting the height in Modal windows doesn't work.
-
I had the same problem, but your code sample worked for me.
-
Create the modal with backgroundColor like 'rgba(r,g,b,a)' and then add a view with left and right values around 50.