【问题标题】:bring window to front of another window titanium将窗口带到另一个窗口的前面钛
【发布时间】:2016-03-02 14:37:01
【问题描述】:

我有两个窗口

窗口 1:

var win = Ti.UI.createWindow({
    backgroundColor : 'black',
    url : 'Car.js'
});

窗口 2:

var menuWindow = Ti.UI.createWindow({
    top : 0,
    left : 0,
    width : deviceWidth * 0.0000001,
    toogle : false,
});

win.open();
menuWindow.open();

在占据整个屏幕的第一个窗口中,我需要像使用“url:'Car.js'”一样输入一个 .js 文件。第二个窗口被隐藏,当我在第一个窗口上滑动时,第二个窗口必须出现在第一个窗口的上方。如何将一个窗口置于前面并将另一个窗口保持在背景中?

【问题讨论】:

    标签: android ios iphone titanium titanium-mobile


    【解决方案1】:

    @Manuel_Rodrigues 我们只需要在“新窗口”中添加一些属性就可以做到这一点(这里是例子):

    1.win.js

    var win = Ti.UI.createWindow({
        width: '100%',
        height: '100%',
        backgroundColor: 'white'
    });
    
    //sliding animation
    var slide_to_right = Ti.UI.createAnimation({
        left: 0,
        duration: 200
    });
    
    //win swipe listener
    win.addEventListener('click',function(e){
        if(e.direction == 'right'){         //swipe to right open the menuWindow
            //Alloy
            var menu_win = Alloy.createController('menu_window').getView();
            menu_win.setLeft('-100%');      //menuWindow will open with a sliding animation from left
            menu_win.open(slide_to_right); 
    
            /*
            //not Alloy
            var menuWin = require('/menu_window');    //path of menu_window.js
            var menuWindow = new menuWin();
            menuWindow.open(slide_to_right);
            */
        }
    });
    win.open();
    

    2.menu_window.js

    //Alloy
    var menuWindow = Ti.UI.createWindow({
        width: '40%',
        height: '100%',
        backgroundColor: 'transparent',
        theme: 'Theme.AppCompat.Translucent.NoTitleBar'    //backgroundColor set 'transparent' make the menuWindow seems suspend above the win-window, the 'theme' property just remove the window default tile navigation-bar in android  
    });
    menuWindow.open();
    
    /*
    //not Alloy
    function menuWin(){
        var menuWindow = Ti.UI.createWindow({
            width: '40%',
            height: '100%',
            backgroundColor: 'transparent',
            theme: 'Theme.AppCompat.Translucent.NoTitleBar'
        });
        return menuWindow;
    }
    
    module.exports = menuWin;
    */
    

    因此,完成您想要的事情的关键是将 backgroundColortheme 属性设置为新的另外,定义一个打开动画来改变窗口打开的system-default-animation。但是,我不建议您使用这种方式,因为不需要将 menu(您希望在基本窗口中显示的)定义为窗口 UI 组件,您只需将菜单定义为view 会在您执行滑动操作后显示。我认为这对你也有用,而且效果更好。

    希望这些对您有所帮助!祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多