Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// AnimateFontWeightView.swift
// 100DaysOfSwiftUI
//
// Created by amos.gyamfi@getstream.io on 11.6.2022.
//
import SwiftUI
struct AnimateFontWeightView: View {
@State private var isMagicallyMoving = false
var body: some View {
Text("Animate SwiftUI Text Like Your Boss' Boss!")
.font(.title)
.fontWeight(isMagicallyMoving ? .black : .ultraLight)
.multilineTextAlignment(.center)
//Investigate: Animating gradient with foreground style
// The foreground color animation is new in iOS 16
.foregroundColor(isMagicallyMoving ? .indigo : .cyan)
//.animation(.easeInOut(duration: 1).delay(0.5).repeatForever(autoreverses: true), value: isMagicallyMoving)
.animation(.interpolatingSpring(stiffness: 170, damping: 15).repeatForever(autoreverses: true), value: isMagicallyMoving)
.onAppear {
isMagicallyMoving.toggle()
}
}
}
struct AnimateFontWeightView_Previews: PreviewProvider {
static var previews: some View {
AnimateFontWeightView()
.preferredColorScheme(.dark)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment