swift基础之swiftui中的动画

原创
2021/04/19 17:03
阅读数 86

withAnimation

import SwiftUI

struct AnimationView: View {

    @State private var showDetail = false
    
    var body: some View {
        Button(action: {
            withAnimation{
                self.showDetail = !self.showDetail
            }
        }) {
            Image(systemName: "chevron.right.circle")
                .imageScale(.large)
                .rotationEffect(.degrees(showDetail ? 90 : 0))
                .scaleEffect(showDetail ? 1.5 : 1)
                .padding()
        }
    }
}

struct AnimationView_Previews: PreviewProvider {
    static var previews: some View {
        AnimationView()
    }
}
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部