Animation 钛动画标签颜色
请参阅以下在Appcelerator Studio SDK 5.2.0.GA中测试的代码片段:Animation 钛动画标签颜色,animation,appcelerator,appcelerator-titanium,Animation,Appcelerator,Appcelerator Titanium,请参阅以下在Appcelerator Studio SDK 5.2.0.GA中测试的代码片段: // // create base UI tab and root window // var win0 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var label0 = Titanium.UI.createLabel({ color:'red', text:'I
//
// create base UI tab and root window
//
var win0 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var label0 = Titanium.UI.createLabel({
color:'red',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
view0 = Titanium.UI.createView({
borderRadius:10
,width: 350
,height:40
,opacity:1
,color:"blue"
});
view0.add(label0);
win0.add(view0);
win0.open();
// Working
//win0.animate({backgroundColor:"blue", duration: 1000});
// Working
//view0.animate({backgroundColor:"blue", duration: 1000});
// Working
//label0.animate({backgroundColor:"blue", duration: 1000});
// "Working", but there is no duration (animation takes place right away)
label0.animate({color:"blue", duration: 1000});
// "Working", but there is no duration (animation takes place right away after the timer 5 sec timeout)
//setTimeout(function(){
// label0.animate({color:"blue", duration: 1000});
//},5000);
// If win0.open is placed before the code below, there is no animation at all.
// If win0.open is placed after the code below, there is animation, but it takes place right away.
//win0.addEventListener('postlayout', function(e){
// label0.animate({color:"blue", duration: 1000});
//});
该代码创建了一个包含一个视图和一个标签的窗口
带有动画的4行一次测试一行(即,要测试,一次取消注释一行)。第一个在1秒内设置窗口背景色的动画。工作正常。第二个设置视图背景颜色的动画,效果正常。第三个设置标签背景色的动画,效果正常。第四个用于设置标签文本颜色的动画。这并不像人们所期望的那样有效。动画会发生,但会立即发生,而不是在1秒内
你知道代码或其他东西有什么问题吗?也许你看不到动画,因为它是在打开窗口后调用的。尝试添加设置超时:
setTimeout(function(){
label0.animate({color:"blue", duration: 1000});
},5000);
或者,在“窗口布局后”事件之后执行动画:
也许你看不到动画,因为它是在打开窗口后调用的。尝试添加设置超时:
setTimeout(function(){
label0.animate({color:"blue", duration: 1000});
},5000);
或者,在“窗口布局后”事件之后执行动画:
我尝试了注释中的两个新代码示例,但没有一个给出动画期间的持续时间,它仍然立即发生。。。想到背景颜色的动画效果确实与动画持续时间有关,这些示例是否应该起作用,这不是有点令人困惑吗?我尝试了注释中的两个新代码示例,但没有一个给出动画期间的持续时间,它仍然会立即发生。。。考虑到背景颜色的动画制作确实与动画持续时间有关,如果这些示例本应起作用,这不是有点令人困惑吗?