Qml侧边滑动菜单

作者: zhengtianzuo | 来源:发表于2018-11-29 20:24 被阅读0次
    Rectangle {
            anchors.fill: parent
            color: "#AAAAAA";
            opacity: bMenuShown ? 1 : 0
            Behavior on opacity {
                NumberAnimation {
                    duration: 300
                }
            }
        }
    
        Rectangle {
            anchors.fill: parent
            color: "#FFFFFF"
            opacity: bMenuShown ? 0.5 : 1
            Behavior on opacity {
                NumberAnimation {
                    duration: 300
                }
            }
    
            Button {
                width: 48
                height: 48
                text: qsTr("菜单")
                onClicked: onMenu();
            }
    
            transform: Translate {
                id: menuTranslate
                x: 0
                Behavior on x {
                    NumberAnimation {
                        duration: 400;
                        easing.type: Easing.OutQuad
                    }
                }
            }
            MouseArea {
                anchors.fill: parent
                enabled: bMenuShown
                onClicked: onMenu();
            }
        }
    
        function onMenu()
        {
            menuTranslate.x = bMenuShown ? 0 : width * 0.8
            bMenuShown = !bMenuShown;
        }
    
    show.gif

    需要完整代码请访问QtQuickExamples

    相关文章

      网友评论

        本文标题:Qml侧边滑动菜单

        本文链接:https://www.haomeiwen.com/subject/sjkqcqtx.html