AnchorAnimation
一、描述
AnchorAnimation 用于为锚点更改设置动画。
在下面的代码片段中,我们将右锚点添加到 Rectangle 动画:
import QtQuick 2.9
import QtQuick.Window 2.2
Window
{
visible: true
width: 800
height: 800
Rectangle
{
id: container
width: 200
height: 200
color: "blue"
Rectangle
{
id: myRect
width: 100
height: 100
color: "red"
}
states: State
{
name: "reanchored"
AnchorChanges
{
target: myRect
anchors.right: container.right
}
}
transitions: Transition
{
AnchorAnimation { duration: 1000 }
}
Component.onCompleted: container.state = "reanchored"
}
}
在 Transition 中使用 AnchorAnimation 时,它将为状态更改期间发生的任何 AnchorChanges 设置动画。
AnchorAnimation 只能用于 Transition 并与 AnchorChange 结合使用。它不能用于Behaviors 和其他类型的动画。
二、属性成员
1、duration : int
此属性保存动画的持续时间,以毫秒为单位。默认值为 250。
2、曲线组
easing.amplitude : real
easing.overshoot : real
easing.period : real
easing.type : enumeration
指定用于动画的缓动曲线。见曲线组。
3、targets : list<Item>
要重新锚定的项目。
如果没有指定目标,则 AnchorAnimation 将设置所有 AnchorChanges 的动画。
AnchorChanges
一、描述
AnchorChanges 类型用于修改 State 中项目的锚点。
二、属性成员
1、anchors group
锚。
2、target : Item
此属性保存将应用锚点更改的项目。