QML 发光呼吸动画字体
生活随笔
收集整理的這篇文章主要介紹了
QML 发光呼吸动画字体
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
用 QML 來實現一個呼吸動畫效果的字體,非常酷炫,主要使用 Glow 組件來實現,然后通過控制透明度的改變來實現想要的效果,代碼非常簡單。
正文
先來看看效果
源碼:
Item {Rectangle {anchors.fill: parentcolor: "black"}Text {id: textanchors.fill: parenttext: qsTr("ADBASn你好")font.bold: truefont.pixelSize: 50color:"white"horizontalAlignment: Text.AlignHCenterverticalAlignment: Text.AlignVCenter}Glow {anchors.fill: textradius:9samples: 13color: "#ddd"source: textspread: 0.5opacity: 0.8NumberAnimation on opacity {id:an1to:0.8duration: 2000running: trueonStopped: {an2.start()}}NumberAnimation on opacity {id:an2to:0.2duration: 2000onStopped: {an1.start()}}} }此外,還可以通過修改 Glow 的參數來實現不同的效果,具體可以看 Qt 幫助文檔。
源碼在這里點擊下載
總結
以上是生活随笔為你收集整理的QML 发光呼吸动画字体的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Qt 加载QML 文件的几种方式
- 下一篇: QML实现酷炫的 Cover Flow