Schlange wie Gradientengrenzanimation in iOSIOS

Programmierung für iOS
Anonymous
 Schlange wie Gradientengrenzanimation in iOS

Post by Anonymous »

Ich versuche, Schlangenbetriebs -Randanimation mit Gradientenfarbe anzusehen, siehe das Bild unten. Es kommt als Hintergrundansicht nicht als Rand. Unten ist der Swiftui -Code, den ich verwendet habe: < /p>

Code: Select all

struct GradientBorderAnimationView: View {
@State var rotation:CGFloat = 0.0

@State var width: CGFloat = 330
@State var height: CGFloat = 100

var body: some View {
ZStack{
RoundedRectangle(cornerRadius: 20, style: .continuous)
.frame(width: width*2, height: height*2)
.foregroundStyle(LinearGradient(gradient: Gradient(colors: [.white, .white, .blue]),
startPoint: .top,
endPoint: .bottom))
.rotationEffect(.degrees(rotation))
.mask {
RoundedRectangle(cornerRadius: 20, style: .continuous)
.stroke(lineWidth: 3)
.frame(width: width, height: height)
}
}
.ignoresSafeArea()
.onAppear{
withAnimation(.linear(duration: 4).repeatForever(autoreverses: false)){
rotation = 360
}
}
}
}
Ausgabe:

erwartete Ausgabe:

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post