//
// ContentView.swift
// SwiftUIProject
//
// Created by Cairocoders
//
import SwiftUI
struct ContentView: View {
@State var user: Userlist?
var body: some View {
VStack {
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .center, spacing: 230) {
ForEach(users) { rs in
GeometryReader { geometry in
Image(rs.photo)
.resizable().frame(width: 210, height: 350, alignment: .center).cornerRadius(16)
.overlay(RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray, lineWidth: 4)
.frame(width: 210, height: 350, alignment: .center)
.cornerRadius(16)
.shadow(color: Color.gray.opacity(0.2), radius: 20, x: 0, y: 0)
)
.shadow(radius: 16)
.rotation3DEffect(Angle(degrees: (Double(geometry.frame(in: .global).minX) - 210) / -20), axis: (x: 0, y: 1.0, z: 0))
HStack {
Text(rs.username)
.foregroundColor(.white)
.font(.title)
}.frame(width: 210, alignment: .center)
}
}
}.padding(.horizontal, 210)
.padding(.top, 150)
}
}
.background(Color.gray)
.edgesIgnoringSafeArea(.all)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct Userlist: Identifiable {
let id: Int
let username: String
let photo : String
}
var users = [
Userlist(id: 0, username: "Olivia", photo: "1"),
Userlist(id: 1, username: "Emma", photo: "2"),
Userlist(id: 2, username: "Ava", photo: "3"),
Userlist(id: 3, username: "Charlotte", photo: "4"),
Userlist(id: 4, username: "Sophia", photo: "5"),
Userlist(id: 5, username: "Caite", photo: "6"),
Userlist(id: 6, username: "Amelia", photo: "7")
]
article
Sunday, March 6, 2022
SwiftUI 3D Scroll Effect
SwiftUI 3D Scroll Effect