[SwiftUI] TabView, TabViewStyle
Language/Swift2022. 9. 12. 17:15[SwiftUI] TabView, TabViewStyle

TapView : A view that switches between multiple child views using interactive user interface elements. To create a user interface with tabs, place views in a TabView and apply the tabItem(_:) modifier to the contents of each tab. On iOS, you can also use one of the badge modifiers, like badge(_:), to assign a badge to each of the tabs. Use a Label for each tab item, or optionally a Text, an Imag..

[SwiftUI] ScrollView
Language/Swift2022. 9. 12. 16:32[SwiftUI] ScrollView

ScrollView : A scrollable view The scroll view displays its content within the scrollable content region. As the user performs platform-appropriate scroll gestures, the scroll view adjusts what portion of the underlying content is visible. ScrollView can scroll horizontally, vertically, or both, but does not provide zooming functionality. var body: some View { ScrollView { VStack(alignment: .lea..

[SwiftUI] NavigationView
Language/Swift2022. 9. 12. 14:02[SwiftUI] NavigationView

NavigationView Deprecated A view for presenting a stack of views that represents a visible path in a navigation hierarchy Deprecated (22. 9. 12.) Use NavigationStack and NavigationSplitView instead. For more information, see Migrating to new navigation types. Use a NavigationView to create a navigation-based app in which the user can traverse a collection of views. Users navigate to a destinatio..

[SwiftUI] @Environment
Language/Swift2022. 9. 12. 12:14[SwiftUI] @Environment

@Environment : A property wrapper that reads a value from a view’s environment Use the Environment property wrapper to read a value stored in a view’s environment. Indicate the value to read using an EnvironmentValues key path in the property declaration. For example, you can create a property that reads the color scheme of the current view using the key path of the colorScheme property: @Enviro..

[SwiftUI] @State @binding
Language/Swift2022. 9. 12. 10:27[SwiftUI] @State @binding

@State : A property wrapper type that can read and write a value managed by SwiftUI SwiftUI manages the storage of a property that you declare as state. When the value changes, SwiftUI updates the parts of the view hierarchy that depend on the value. Use state as the single source of truth for a given value stored in a view hierarchy. A State instance isn’t the value itself; it’s a means of read..

[Swift] xcode template file modified, Add Snippet
Language/Swift2022. 9. 10. 21:59[Swift] xcode template file modified, Add Snippet

저는 swiftUI 파일을 수정하는 방법을 아래와 같이 설명하였습니다. // in terminal cd /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/User Interface/SwiftUI View.xctemplate open . 해당 주소로 접근하게 되면 ___FILEBASENAMEASIDENTIFIER___.swift 의 파일이 존재합니다. 해당 파일은 기존에 swift 파일 생성 시 만들어질 때 사용되는 것으로 잠김 파일이지만, 복제 후 교체하여 해당 파일을 원하는 형태로 수정을 하였습니다. //___FILEHEADER___ import SwiftUI struct ___FI..

[SwiftUI] @appstorage
Language/Swift2022. 9. 8. 21:15[SwiftUI] @appstorage

@appstorage (참고) : UserDefaults의 값을 반영하고 해당 사용자 기본값의 값 변경에 대한 보기를 무효화하는 Property Wrapper 유형입니다. appstorage를 알고 싶은 거였는데, 모르는 단어 UserDefaults와 Property Wrapper가 나왔습니다. 간단하게 설명을 하고 넘어가도록 하겠습니다. UserDefaults (참고) 앱을 실행하는 동안 지속적으로 키-값 쌍을 저장하는 사용자의 기본 데이터베이스에 대한 인터페이스입니다. UserDefaults는 앱을 종료한 다음 다시 실행해도 그대로 유지되므로 앱 구성 데이터를 저장하는 데 이상적인 방법입니다. let defaults = UserDefaults.standard defaults.set(25, forKey..

[SwiftUI] preview가 뭔데요?
Language/Swift2022. 9. 8. 11:17[SwiftUI] preview가 뭔데요?

swiftUI file을 생성하게 되면 preview 함수가 만들어져 있는 것을 볼 수 있습니다. preview의 역할은 시뮬레이터를 실행시키지 않고도 화면이 어떻게 보여지는 건지 바로 확인을 할 수 있게 만들어줍니다. 동작은 어떻게 하는 지 먼저 보자면, 현재 소스 에디터에 PreviewProvider프로토콜을 준수하는 타입이 존재하는지 확인 PreviewProivder프로토콜의 필수 구현 사항인 previews 타입 프로퍼티에서 뷰 생성 액티브 스킬의 목적지로 선택한 시뮬레이터 또는 맥에 연결한 기기의 형태로 preview container 렌더링 리뷰 컨테이너를 직접 지정해 줄 경우 3번 에서 선택한 기기를 무시하고 해당 기기 형태로 렌더링 코드에서 보면 HomeView()라는 함수를 동작시키게 되..

image