Hello,
I wonder if you can help me…
Im trying to have a gradient background on my app, with an animation on top. I want the gradient to go from the top left corner to the bottom right. So far its proving to be very difficult! please see the code below. I apologise in advance if I have made any glaring errors but I’m very new to this.
struct LaunchScreenView: View {
@State var isAnimating = false
@State var image = "Link logo"
var body: some View {
ZStack {
LinearGradient(gradient: .init(colors: [UIColor.cyan.cgColor, UIColor.magenta.cgColor]), startPoint = CGPoint(x: 1.0, y: 1.0), endPoint = CGPoint(x: 0.0, y: 0.0)
VStack {
Image("\(image)")
.renderingMode(.template)
.resizable()
.frame(width: 150, height: 150)
.rotationEffect(Angle(degrees: isAnimating ? 1080 : 0))
.animation(
Animation
.easeInOut(duration: 0.7)
.delay(isAnimating ? 0.5 : 0)
.repeatForever(autoreverses: false)
)
.scaleEffect(isAnimating ? 1 : 0)
.animation(
Animation
.easeInOut(duration: 0.7)
.delay(isAnimating ? 0.5 : 0)
.repeatForever(autoreverses: true)
)
}.frame(width: 213, height: 213)
.onAppear(){
Timer.scheduledTimer(withTimeInterval: 2.4, repeats: true) {_ in self.image = ""
}
self.isAnimating = true
}.foregroundColor(Color.black).opacity(1)
}.edgesIgnoringSafeArea(.all)
}
}
struct LaunchScreenView_Previews: PreviewProvider {
static var previews: some View {
LaunchScreenView()
}
}