Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created June 14, 2022 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/231dcb3574c785488f183a3ff9137b38 to your computer and use it in GitHub Desktop.
Save amosgyamfi/231dcb3574c785488f183a3ff9137b38 to your computer and use it in GitHub Desktop.
//
// 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