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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | // // 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