Created
June 14, 2022 19:21
-
-
Save amosgyamfi/231dcb3574c785488f183a3ff9137b38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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