如何使用Appcelerator从底部翻转iOS视图



我有一个应用程序,它使用 appcelerator 5.1.2 在另一个视图中显示一个视图。

我想将视图动画化为在打开时从底部显示,但无法弄清楚该怎么做。

我已经做了完全相反的事情,那就是让它消失在底部。这是代码:

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

可以将起始顶部值设置为 platformHeight,然后将 top 动画设置为0。此外,将该视图的高度设置为平台高度。对于 iOS,您还可以将外视图剪辑模式设置为Titanium.UI.iOS.CLIP_MODE_ENABLED

编辑:完整示例

index.tss

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

索引.xml

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

索引.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();

最新更新