如何为钛制作幻灯片动画
How to make slide animation for titanium
我有一个 window 和一个视图,这个视图覆盖了屏幕的 76%。
var win = Ti.UI.createWindow({
backgroundColor: 'white',
navBarHidden: true,
});
var view = Ti.UI.createView({
backgroundColor:backgroundColor ,
width:'76%',right:0,left:'24%',
height:'100%'
});
win.addEventListener('click',function(e){
win.add(view);
});
我想做的是从屏幕右侧滑动视图。
我该怎么做呢?
我想我应该使用 animate 方法 ,
有没有人有样本源之类的??
要制作动画,您确实需要使用 animate
方法。
这是一个例子:
var view = Ti.UI.createView({
backgroundColor:'yellow',
width:'76%',
right:-Ti.Platform.displayCaps.getPlatformWidth(),
onScreen:false
});
win.tiview.add(view);
win.tiview.addEventListener('click',function(e){
var viewShowAnimation = Ti.UI.createAnimation({
duration:250,
right:0
});
var viewHideAnimation = Ti.UI.createAnimation({
duration:250,
right:-Ti.Platform.displayCaps.getPlatformWidth()
});
if(view.onScreen){
view.animate(viewShowAnimation);
}else{
view.animate(viewHideAnimation);
}
view.onScreen = !view.onScreen;
});
我有一个 window 和一个视图,这个视图覆盖了屏幕的 76%。
var win = Ti.UI.createWindow({
backgroundColor: 'white',
navBarHidden: true,
});
var view = Ti.UI.createView({
backgroundColor:backgroundColor ,
width:'76%',right:0,left:'24%',
height:'100%'
});
win.addEventListener('click',function(e){
win.add(view);
});
我想做的是从屏幕右侧滑动视图。 我该怎么做呢? 我想我应该使用 animate 方法 , 有没有人有样本源之类的??
要制作动画,您确实需要使用 animate
方法。
这是一个例子:
var view = Ti.UI.createView({
backgroundColor:'yellow',
width:'76%',
right:-Ti.Platform.displayCaps.getPlatformWidth(),
onScreen:false
});
win.tiview.add(view);
win.tiview.addEventListener('click',function(e){
var viewShowAnimation = Ti.UI.createAnimation({
duration:250,
right:0
});
var viewHideAnimation = Ti.UI.createAnimation({
duration:250,
right:-Ti.Platform.displayCaps.getPlatformWidth()
});
if(view.onScreen){
view.animate(viewShowAnimation);
}else{
view.animate(viewHideAnimation);
}
view.onScreen = !view.onScreen;
});