Skip to content

Latest commit

 

History

History
75 lines (63 loc) · 2.51 KB

README.md

File metadata and controls

75 lines (63 loc) · 2.51 KB

SwiftUI-Layout-Practice

screenshot_1

This project is for learning SwiftUI. We are mainly committing layout samples.

Environment

Xcode11.1
SwiftUI
Mac OS 10.15(19A583)

Layout_1 CardListView

This layout is simply Card List Layout.

screenshot_1

Layout_2 SideMenuView

This layout is Side Menu Layout.
This is a sample layout that displays the side menu when you tap the button.

screenshot_1

Layout_3 CardAnimationView

This is Card Animation Layout.

screenshot_1

Tap the card to enlarge the view to the full screen size.
Since the animation is attached, the view can be enlarged smoothly.
The display logic is very simple.
Use the @State modifier to bind button taps.
Next, simply use the ternary operator to set the properties used in @State in the View frame.

struct CardAnimationView: View {
    @State var show = false
    
    var body: some View {
        Button(action: {
            withAnimation {
                self.show.toggle()
            }
        }) {
            VStack() {
                Text("SwiftUI-Layout")
                    .foregroundColor(.white)
                    .fontWeight(.bold)
                    .font(.largeTitle)
                    .padding(.top, show ? 100 : 20)
                Spacer()
            }
            .padding()
            .frame(width: show ? ScreenSize.width : 300, height: show ? ScreenSize.height : 300)
            .background(Color.blue)
        }
        .cornerRadius(30)
        .animation(.spring())
    }
}

Layout_4 UserDefaultTest

This is UserDefautlt Test by PropertyWrappers.

screenshot_1

Layout_5 now making...