0

I'm doing currently an animated pulsing play button with swiftUI. Everything works, but the animation starts in from the upper left corner somehow Here is a screenshot. Example 1

Example 2

But the filled Circle() should be behind the play.fill icon and the stroke should just pulse of it The code I used to make it is this one

import SwiftUI

struct PlayView: View {
    @State private var pulsate = false
    @State private var showWaves = false
    var body: some View {
        ZStack{
            
            Circle()
                .stroke(lineWidth: 2)
                .frame(width: 100, height: 100)
                .foregroundColor(.red)
                .scaleEffect(showWaves ? 2 : 1)
                .hueRotation(.degrees(showWaves ? 360 : 0))
                .opacity(showWaves ? 0 : 1)
                .animation(Animation.easeInOut(duration: 2).repeatForever(autoreverses: false).speed(1))
                .onAppear(){
                    self.showWaves.toggle()
                }
            Circle()
                .frame(width: 100, height: 100)
                .foregroundColor(.red)
                .scaleEffect(pulsate ? 1 : 1.2)
                .animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true).speed(1))
                .onAppear(){
                    self.pulsate.toggle()
                }
            Image(systemName: "play.fill")
                .font(.largeTitle)
                .foregroundColor(.white)
        }.shadow(radius: 25)
        
    }
}


saxonsxexe
  • 97
  • 5
  • Not reproducible with the code you've provided. Please provide a [mre] with the container view that seems like it must be the cause of the issue. – jnpdx May 08 '21 at 18:28
  • 1
    Does this answer your question https://stackoverflow.com/a/66643096/12299030? Or this one https://stackoverflow.com/a/64945673/12299030? – Asperi May 08 '21 at 18:51

0 Answers0