Appcelerator视图隐藏动画
问题描述:
我想在一个模块中集成动画,当单击解除按钮时,整个pendingTasksBar视图的高度变为0dp,但延伸到300ms。这是我到目前为止所尝试过的。有人可以帮我在这里吗?Appcelerator视图隐藏动画
function hidePendingTasksBar(){
log.trace("[tasks] >> [hidePendingTasksBar]");
var animationObj = Ti.UI.createAnimation({
height : "0dp",
duration : 300
});
$.pendingTasksBar.animate(animationObj);
//.pendingTasksBar.height = "0dp";
}
答
高度属性必须是数字,并且您正在使用字符串。我认为这是问题。尝试使用0而不是“0dp”。
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Animation-property-height
答
设置高度,以0作为数字应该工作。如果它不起作用,那么您可以安全地使用矩阵变换来降低高度或将其再次增加到相同高度,如下所示:
var matrix = Ti.UI.create2DMatrix();
matrix = matrix.scale(1, 0);
// to decrease height
$.pendingTasksBar.animate({
duration : 300,
transform : matrix
});
// to reset height
$.pendingTasksBar.animate({
duration : 300,
transform : Ti.UI.create2DMatrix() // use empty matrix & it will reset original matrix or UI.
});