当Image元素的来源被改变时,是否可以有淡入/淡出动画?我需要两个图像元素吗?将其中一个的不透明度从0更改为1,另一个从1更改为0?
这样做没有太多麻烦.以这种方式运行动画:
Image {
id: toBeCreated
NumberAnimation on opacity {
id: createAnimation
from: 0
to: 1
duration: 2000
}
Component.onCompleted: createAnimation.start()
}
Image {
id: toBeDeleted
NumberAnimation on opacity {
id: destroyAnimation // start this animation from the function where you want to create new Images
to: 0
duration: 2000
onRunningChanged: {
if (!running) {
console.log("Destroying...")
toBeDeleted.destroy();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)