-
Notifications
You must be signed in to change notification settings - Fork 16
/
ScaleEffectScrollTransition.swift
43 lines (40 loc) · 1.62 KB
/
ScaleEffectScrollTransition.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// ContentView.swift
// ScaleEffectScrollTransition
//
// Created by Ganesh on 17/06/23.
//
import SwiftUI
struct ScaleEffectScrollTransition: View {
let cellColors: [Color] = [.red, .blue, .green, .orange, .purple]
var body: some View {
ScrollView(.vertical) {
ForEach(0..<50) { index in
let randomColor = cellColors.randomElement() ?? .red
let gradient = LinearGradient(gradient: Gradient(colors: [.black, randomColor]), startPoint: .topLeading, endPoint: .bottomTrailing)
Text("Cell: \(index)")
.font(.title)
.frame(maxWidth: .infinity)
.frame(height: 200)
.foregroundColor(.white)
.background(
ZStack {
RoundedRectangle(cornerRadius: 20)
.fill(gradient)
.shadow(color: .black, radius: 10)
RoundedRectangle(cornerRadius: 20)
.fill(Color.white)
.opacity(0.5)
.blur(radius: 5)
RoundedRectangle(cornerRadius: 20)
.stroke(Color.white, lineWidth: 1)
}
)
.padding(.horizontal, 20)
.scrollTransition(topLeading: .animated, bottomTrailing: .animated) { view, transition in
view.rotationEffect(.radians(transition.value))
}
}
}
}
}