2017-03-16 69 views
0

我想製作一個從左側打開的菜單,頂部有一個圖像,然後是幾個重定向到每個頁面的部分。我在網上搜索過,有些發佈了github鏈接,當我去那裏時,我凍結了。不知道我被假定做什麼?我應該安裝什麼?這是一個示例代碼?將不勝感激任何幫助。如何在加速器鈦中創建滑動菜單?

回答

0

你必須爲此使用第三方模塊,他們在市場上有一些。我將舉例說明我使用的一個,或者您可以搜索其他關鍵作品抽屜在鈦

對於安卓https://github.com/viezel/NappDrawer/tree/master/android

var homeScreen = Alloy.createController("homeScreen").getView(); 

var NappDrawerModule = require('dk.napp.drawer'); 
Alloy.Globals.drawer = NappDrawerModule.createDrawer({ 
    fullscreen : false, 
    leftWindow : Alloy.createController('leftMenu').getView(), 
    centerWindow : homeScreen, 
    fading : 0.2, // 0-1 
    parallaxAmount : 0.2, //0-1 
    exitOnClose : true, 
    shadowWidth : "5dp", 
    leftDrawerWidth : "280dp", 
    animationMode : NappDrawerModule.ANIMATION_NONE, 
    closeDrawerGestureMode : NappDrawerModule.CLOSE_MODE_NONE, 
    openDrawerGestureMode : NappDrawerModule.OPEN_MODE_NONE, 
    orientationModes : [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT] 
}); 

Alloy.Globals.drawer.addEventListener("didChangeOffset", function(e) { 
    //Ti.API.info("didChangeOffset: " + e.offset); 
}); 
Alloy.Globals.drawer.addEventListener("android:back", function(e) { 
    Ti.API.info('currentWindow : ' + Alloy.Globals.currentWindow); 
    if (Alloy.Globals.currentWindow != null) { 
     return; 
    } 
}); 

Alloy.Globals.drawer.addEventListener("windowDidOpen", function(e) { 

    if (e.window == NappDrawerModule.LEFT_WINDOW) { 
     Ti.API.info("windowDidOpen - LEFT DRAWER"); 
    } else if (e.window == NappDrawerModule.RIGHT_WINDOW) { 
     Ti.API.info("windowDidOpen - RIGHT DRAWER"); 
    } 

}); 

Alloy.Globals.drawer.addEventListener("open", function(e) { 
     Ti.API.info('Drawer Open'); 
}); 

Alloy.Globals.drawer.addEventListener("windowDidClose", function(e) { 
    Ti.API.info("windowDidClose"); 
}); 

// lets open it 
Alloy.Globals.drawer.open(); 

對於iOS:https://github.com/viezel/NappSlideMenu

Alloy.Globals.SlideWindow = Alloy.createController("leftMenu"); 
var homeWindow = Alloy.createController("homeScreen").getView(); 

var NappSlideMenu = require('dk.napp.slidemenu'); 

var window = NappSlideMenu.createSlideMenuWindow({ 
    centerWindow : homeWindow, 
    leftWindow : Alloy.Globals.SlideWindow.getView(), 
    leftLedge : (Alloy.Globals.iPad) ? 170 : 70, 
    parallaxAmount : 0.2, 
}); 

Alloy.Globals.window = window; 

window.addEventListener("viewWillOpen", function(e) { 
}); 

window.addEventListener("viewWillClose", function(e) { 
}); 

exports.openLeft = function() { 
    window.toggleLeftView(); 
}; 

exports.openRight = function() { 
    window.toggleRightView(); 
}; 

window.open(); 

注:對於Android,leftMenuhomeScreenView,但對於iOS,它是Window

好運,乾杯