Skip to content

Commit

Permalink
[feat] title animation
Browse files Browse the repository at this point in the history
  • Loading branch information
mrs1669 committed May 22, 2024
1 parent 5fb09cd commit 9830786
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions PrimePickApp/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,44 @@
import SwiftUI

struct MainView: View {
@State private var hue: Double = 0

var body: some View {
NavigationStack {
ZStack {
Color("appBlue")
.ignoresSafeArea()

VStack {
Text("PrimePick")
.font(.custom("Helvetica Neue", size: 40))
Spacer()

Text("Prime Pick")
.font(.custom("Helvetica Neue", size: 60))
.foregroundStyle(.black)
.fontWeight(.bold)
.padding(.top, 100)
.padding(.bottom, 30)
.offset(x: 2, y: 2)
.foregroundColor(Color.white) // 文字自体を白に設定
.overlay(
LinearGradient(
gradient: Gradient(colors: [
Color.red, Color.orange, Color.yellow, Color.green,
Color.blue, Color.purple, Color.red
]),
startPoint: .leading,
endPoint: .trailing
)
.mask(
Text("Prime Pick")
.font(.custom("Helvetica Neue", size: 60))
.fontWeight(.bold)
)
.hueRotation(Angle(degrees: hue))
)
.onAppear {
withAnimation(Animation.linear(duration: 1).repeatForever(autoreverses: false)) {
hue = 360
}
}

Spacer()

Expand Down Expand Up @@ -105,6 +131,21 @@ struct LazyView<Content: View>: View {
}
}

struct RainbowTextModifier: AnimatableModifier {
var hue: Double

var animatableData: Double {
get { hue }
set { hue = newValue }
}

func body(content: Content) -> some View {
content
.foregroundColor(Color(hue: hue, saturation: 1, brightness: 1))
.animation(Animation.linear(duration: 2).repeatForever(autoreverses: false))
}
}

#Preview {
MainView()
}

0 comments on commit 9830786

Please sign in to comment.