Swiftui 3D按钮效果

Swiftui 3D按钮效果,第1张

import SwiftUI

struct ExplicitAnimationContentView: View {

    @State private var animationAmount = 0.0

    var body: some View {

        Button("点我") {

            withAnimation(.interpolatingSpring(stiffness: 3, damping: 5)) {

                self.animationAmount += 360

            }

        }

        .padding(50)

        .background(Color.red)

        .foregroundColor(.white)

        .clipShape(Circle())

        .rotation3DEffect(.degrees(animationAmount), axis: (x: 0, y: 1, z: 0))

    }

}

struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ExplicitAnimationContentView()

    }

}

 

 

 

 

 

 

 

 

 

 

 

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/990122.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存