欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

QML----StackView动画

程序员文章站 2022-05-03 10:54:03
...

废话不多说,直接上代码(这里是渐入溅出)

StackView{
	objectName: "rootStack"
	id:stackView
	initialItem: spalsh
	anchors.fill: parent
	replaceEnter: Transition {
		PropertyAnimation {
			target: stackView
			property: "opacity"
			from: 0
			to: 1
			duration:700
			easing.type: Easing.InOutElastic;
			easing.amplitude: 2.0;
			easing.period: 1.5
		}
	}
	replaceExit: Transition {
		PropertyAnimation {
			target: stackView
			property: "opacity"
			from: 1
			to: 0
			duration:500
			easing.type: Easing.InOutElastic;
			easing.amplitude: 2.0;
			easing.period: 1.5
		}
	}
}

replace动画替换:

注意:

  1. Exit动画多于Enter时间会白屏。
  2. stackview动画尽量不要用弹性渐入溅出,导致闪屏
  3. enter和exit不要有太长的时间间隔。