ContentView.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 | // // ContentView.swift // swiftuidev15ios // // Created by Cairocoders // import SwiftUI struct ContentView: View { var body: some View { ZStack { Color.gray .ignoresSafeArea() Text( "ContentView" ) .foregroundColor(.white) .font(. system (size: 20)) .bold() .padding() } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } |
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 | // // SplashScreenView.swift // swiftuidev15ios // // Created by Cairocoders // import SwiftUI struct SplashScreenView: View { @State var isActive : Bool = false @State private var size = 0.8 @State private var opacity = 0.5 var body: some View { if isActive { ContentView() } else { VStack { VStack { Image( "logo" ) .resizable() .scaledToFill() .frame(width: 128, height: 128) Text( "Cairocoders" ) .font(Font.custom( "Baskerville-Bold" , size: 26)) .foregroundColor(.black.opacity(0.80)) } .scaleEffect(size) .opacity(opacity) .onAppear { withAnimation(.easeIn(duration: 1.1)) { self.size = 0.9 self.opacity = 1.00 } } } .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { withAnimation { self.isActive = true } } } } } } struct SplashScreenView_Previews: PreviewProvider { static var previews: some View { SplashScreenView() } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // // swiftuidev15iosApp.swift // swiftuidev15ios // // Created by Cairocoders // import SwiftUI @main struct swiftuidev15iosApp: App { var body: some Scene { WindowGroup { SplashScreenView() } } } |