0
考慮以下QML代碼:QML:意外AnchorAnimation行爲
import QtQuick 2.0
Item{
id:window
anchors.fill:parent
transitions:Transition{AnchorAnimation{duration:500}}
Rectangle{
id:topBar
anchors{left:parent.left;right:parent.right;bottom:parent.top}
height:100
color:'red'
border.width:1
}
Rectangle{
id:bottomBar
anchors{left:parent.left;right:parent.right;top:parent.bottom}
height:100
color:'blue'
border.width:1
}
states:State{
name:'on'
AnchorChanges{target:topBar;anchors.top:parent.top;anchors.bottom:undefined}
AnchorChanges{target:bottomBar;anchors.bottom: parent.bottom;anchors.top:undefined}
}
Component.onCompleted:{window.state='on'}
}
這是相當簡單:在窗口創建,頂欄滑入視圖從頂部和底部的bottomBar。
topBar完全按照它的設想進行,但bottomBar不會:動畫發生在頂部(與topBar重疊),並在動畫完成時出現在窗口的底部。
發生了什麼事?
就是這樣!非常感謝你。 –