Last active
November 21, 2019 14:11
-
-
Save rudrankriyam/989582cf6afef86e0e7d63d5258363cd to your computer and use it in GitHub Desktop.
Creating an Apple like Splash Screen in SwiftUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ButtonModifier: ViewModifier { | |
| func body(content: Content) -> some View { | |
| content | |
| .foregroundColor(.white) | |
| .font(.system(.headline, design: .rounded)) | |
| .padding() | |
| .frame(minWidth: 0, maxWidth: .infinity, alignment: .center) | |
| .background(RoundedRectangle(cornerRadius: 15, style: .continuous) | |
| .fill(Color.mainColor)) | |
| .padding(.bottom) | |
| } | |
| } | |
| extension Text { | |
| func customTitleText() -> Text { | |
| self | |
| .fontWeight(.black) | |
| .font(.system(size: 36, design: .rounded)) | |
| } | |
| } | |
| extension Color { | |
| static var mainColor = Color(UIColor.systemIndigo) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct InformationContainerView: View { | |
| var body: some View { | |
| VStack(alignment: .leading) { | |
| InformationDetailView(title: "Match", subTitle: "Match the gradients by moving the Red, Green and Blue sliders for the left and right colors.", imageName: "slider.horizontal.below.rectangle") | |
| InformationDetailView(title: "Precise", subTitle: "More precision with the steppers to get that 100 score.", imageName: "minus.slash.plus") | |
| InformationDetailView(title: "Score", subTitle: "A detailed score and comparsion of your gradient and the target gradient.", imageName: "checkmark.square") | |
| } | |
| .padding(.horizontal) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct InformationDetailView: View { | |
| var title: String = "title" | |
| var subTitle: String = "subTitle" | |
| var imageName: String = "gradientsIcon" | |
| var body: some View { | |
| HStack(alignment: .center) { | |
| Image(systemName: imageName) | |
| .font(.largeTitle) | |
| .foregroundColor(.mainColor) | |
| .padding() | |
| VStack(alignment: .leading) { | |
| Text(title) | |
| .fontWeight(.bold) | |
| .foregroundColor(.primary) | |
| Text(subTitle) | |
| .foregroundColor(.secondary) | |
| } | |
| .font(.system(.body, design: .rounded)) | |
| } | |
| .padding(.top) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct IntroductionView: View { | |
| var body: some View { | |
| VStack(alignment: .center) { | |
| TitleView() | |
| InformationContainerView() | |
| Spacer() | |
| Button(action: { | |
| let generator = UINotificationFeedbackGenerator() | |
| generator.notificationOccurred(.success) | |
| }) { | |
| Text("Continue") | |
| .customButton() | |
| } | |
| .padding(.bottom, 5) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct TitleView: View { | |
| var body: some View { | |
| Group { | |
| Image("gradientsIcon") // Add your app logo here | |
| .resizable() | |
| .aspectRatio(contentMode: .fit) | |
| .frame(width: 180, alignment: .center) | |
| Text("Welcome to") | |
| .customTitleText() | |
| Text("Gradients Game") | |
| .customTitleText() | |
| .foregroundColor(.mainColor) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment