QML类型:AnchorAnimation、AnchorChanges

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

此属性保存将应用锚点更改的项目。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值