Animation SwiftUI-如何调整图像不透明度?
我在SwiftUI中有一个图像,我想永远“脉动”(每秒钟左右来来去去一次) 我尝试了很多方法,但似乎都没有达到我想要的效果。我试过的一件事是下面的代码(它似乎什么都不做!)Animation SwiftUI-如何调整图像不透明度?,animation,swiftui,Animation,Swiftui,我在SwiftUI中有一个图像,我想永远“脉动”(每秒钟左右来来去去一次) 我尝试了很多方法,但似乎都没有达到我想要的效果。我试过的一件事是下面的代码(它似乎什么都不做!) 有什么想法吗?这里有一个方法。使用Xcode 11.4/iOS 13.4进行测试 你能解释一下这里发生了什么吗?我不知道值在哪里更改。。。 Image(systemName: "dot.radiowaves.left.and.right" ) .foregroundColor(.blue) .transition(.opa
有什么想法吗?这里有一个方法。使用Xcode 11.4/iOS 13.4进行测试
你能解释一下这里发生了什么吗?我不知道
值
在哪里更改。。。
Image(systemName: "dot.radiowaves.left.and.right" )
.foregroundColor(.blue)
.transition(.opacity)
.animation(Animation.easeInOut(duration: 1)
.repeatForever(autoreverses: true))
struct DemoImagePulsate: View {
@State private var value = 1.0
var body: some View {
Image(systemName: "dot.radiowaves.left.and.right" )
.foregroundColor(.blue)
.opacity(value)
.animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true))
.onAppear { self.value = 0.3 }
}
}