2016-01-17 16 views
0

我有一個應用程序顯示與appcelerator 5.1.2另一個視圖內的視圖。如何從底部翻轉與加速器的iOS視圖

我想動畫視圖從底部出現時打開,但無法弄清楚如何做到這一點。

我已經做了完全相反的事情,那就是讓它消失在底部。下面是代碼:

function closeViewFromBottom(animationView) { 
    var newtop = Ti.Platform.displayCaps.platformHeight + 20; 
    animationView.animate({ 
     top:newtop, 
     duration:1000, 
     autoreverse: false 
    }); 
}; 

回答

0

您可以設置開始頂值platformHeight然後動畫頂部爲0。另外設置以platformHeight的高度。在iOS設備上,你還可以設置外視clipMode到Titanium.UI.iOS.CLIP_MODE_ENABLED

編輯:完整的例子

index.tss

"Window": { 
    backgroundColor: "#fff" 
} 

"#view":{ 
    backgroundColor: "red", 
    width:Ti.UI.FILL, 
    height:Ti.UI.FILL, 
} 

INDEX.XML

<Alloy> 
    <Window > 
     <View id="view"/> 
     <Button id="btn" title="show view"/> 
    </Window>  
</Alloy> 

index.js

$.view.top = Ti.Platform.displayCaps.platformHeight; 

function openViewFromBottom(animationView) { 
    animationView.top = Ti.Platform.displayCaps.platformHeight; 
    animationView.animate({ 
     top:0, 
     duration:1000 
    }); 
}; 

function onClickButton(e){ 
    openViewFromBottom($.view); 
} 
$.btn.addEventListener("click",onClickButton); 
$.index.open(); 
+0

它不起作用,視圖短暫出現在屏幕底部的幾分之一秒內,似乎下降並完全消失在底部以下。 – mostaldev

+0

@mostaldev我認爲這會有助於獲得更多的上下文。你能提供一個完整的(不)工作樣本嗎?一個包含'animationView'的父窗口的窗口,以便更容易測試並幫助您獲得正確的結果? –

+0

@mostaldev你可以請嘗試從'platformHeight - 1'開始。你還有其他TSS適用於視圖嗎? – miga