전체보기 61

[iOS App Dev Tutorials] SwiftUI - State Management (3)

Apple Developer Documentation developer.apple.com 3. Managing State and Life Cycle Section 1. Create an Overlay View struct MeetingView: View { @Binding var scrum : DailyScrum var body: some View { ZStack { RoundedRectangle(cornerRadius: 16.0) VStack{ ... } } } } ZStack를 최상단에 추가해서 앞뒤의 간격을 주었다. ZStack은 먼저 나온 View가 맨 뒤에 배치하게 된다. 따라서 RoundedRectangle이 맨 뒤에 배치되고 그 앞으로 VStack이 나열된다. 그리고 @Binding scru..

[iOS App Dev Tutorials] SwiftUI - State Management (2)

Apple Developer Documentation developer.apple.com 2. Responding to Events Scene Architecture Scene은 시스템이 관리하는 수명주기가 있는 앱의 UI의 일부이다. 앱을 만들기 위해서는 앱 프로토콜을 준수하는 구조를 정의해야한다. @main 속성을 앞에 둠으로써 시작점이 이곳이라는 것을 시스템에게 알릴 수 잇다. 앱 구조 내에 Scene 프토토콜을 준수하는 장면을 하나 이상 추가한다. Scene은 앱이 보여지는 View 계층의 컨테이너이다. 예를 들어 iOS와 watchOS는 하나의 Scene을 보여줄 수 있지만, macOS와 iPadOS는 여러 Scene을 보여줄 수 있다. SwiftUI는 WindowGrouop 같은 원시적인 Sc..

[iOS App Dev Tutorials] SwiftUI - State Management (1)

Apple Developer Documentation developer.apple.com 1. Making Classes Observable Working with Reference Type 이전 챕터에서는 @State, @Binding property wrappers를 사용하여 View 계층에서 업데이트를 트리거하기 위해 진실 소스를 정의했다. 이번에는 앱의 UI에 대한 진실 소스로서 참조 유형을 정의하는 것을 알아본다. @State 은 오직 structures 나 enumerations 같은 Value type (값 타입)에만 작동한다. SwiftUI는 @ObservedObject, @StateObject, @EnvironmentObject 같은 reference type (참조 타입) 을 진실 소스..

[WWDC 2020] Vision

0. 시작에 앞서.. Detect Body and Hand Pose with Vision - WWDC20 - Videos - Apple Developer WWDC 스터디에서 [Detect Body and Hand Pose with Vision] 영상을 보고 각자 공부를 해봤다. Vision 기술을 통해서 얼굴과 몸, 손을 인식하고 움직임까지 감지한다. 이러한 기술을 어떻게 구현하는지 설명하는 동영상이다. 그 중에 손에 대해 요약해서 말하자면 손가락 관절 하나 하나에 포인트(랜드마크)를 찍어서 포인트가 어떻게 변하는지 감지한다. 또한 ARKit 과 Vision의 차이점에 대해서도 설명하고 있다. Landmarks 는 똑같이 제공하고 개수도 같다. Confidence 는 신뢰 값이라고 하는데 Vision만 ..

WWDC 2022.05.13

[iOS App Dev Tutorials] SwiftUI - Passing Data (2)

Apple Developer Documentation developer.apple.com Section 3. Pass the Edit View a Binding to Data struct DetailEditView: View { @Binding var data: DailyScrum.Data ... } struct DetailEditView_Previews: PreviewProvider { static var previews: some View { DetailEditView(data: .constant(DailyScrum.sampleData[0].data)) } } DetailView에서 State 변수를 받기 위해 Binding으로 data 를 선언한다. struct DetailView: View { @..

[iOS App Dev Tutorials] SwiftUI - Navigation and Modal Presentation (3)

Apple Developer Documentation developer.apple.com 3. Creating the Edit View Section 1. Update the Data Model struct Data { var title: String = "" var attendees: [Attendee] = [] var lengthInMinutes: Double = 5 var theme: Theme = .seafoam } var data: Data { Data(title: title, attendees: attendees, lengthInMinutes: Double(lengthInMinutes), theme: theme) } } 아래 data는 DailyScrum의 속성 값을 받고 계산된 데이터를 반환..

[iOS App Dev Tutorials] SwiftUI - Navigation and Modal Presentation (2)

Apple Developer Documentation developer.apple.com 2. Managing Data Flow Between Views @State, @Binding 을 사용하여 사용자 인터페이스가 앱 데이터의 현재 상태를 반영하도록 한다. Source of Truth 정보의 여러 복사본을 관리하면 앱에서 버그를 유발할 수 있다. 따라서 각 데이터 요소에 대해 단일화 한다. 단일 데이터 요소(단일 진실 소스)를 한 곳에 저장하면, 다른 뷰가 동일한 데이터에 액세스 할 수 있다. 데이터를 어디에 저장하는지 정의하는 것은 다양한 뷰에서 공유하는지, 데이터가 변화하는지에 따라 달라진다. Swift Property Wrappers SwiftUI는 @State, @Binding 속성 래퍼를 사용..

[iOS App Dev Tutorials] SwiftUI - Navigation and Modal Presentation (1)

Apple Developer Documentation developer.apple.com 1. Creating a Navigation Hierarchy Section 1. Set Up Navigation @main struct ScrumdingerApp: App { var body: some Scene { WindowGroup { NavigationView { ScrumsView(scrums: DailyScrum.sampleData) } } } } struct ScrumsView: View { let scrums: [DailyScrum] var body: some View { List { ForEach(scrums) { scrum in NavigationLink(destination: Text(scrum..

[iOS App Dev Tutorials] SwiftUI - Views

Apple Developer Documentation developer.apple.com 1. Creating a Card View Color SwiftUI 프레임 워크는 View의 인스턴스로서 color를 다룬다. 에셋 카탈로그와 이름을 같게 enum을 만들어준다. accentColor는 해당 색의 보색으로 강조할 수 있게 만들어 주는 색이다. 그 색에 맞게 하얀색과 검정색을 반환한다. 메인 칼라 함수를 써서 enum의 rawValue를 Color 타입에 넣어 초기화를 한다. View의 background에 theme의 mainColor로 초기화하는 모습 LabelStyle SwiftUI에서 제공하는 LabelStyle 프로토콜을 사용해서 앱 전체에서 일관된 스타일의 레이블을 사용할 수 있게 한다. 여..