본문 바로가기

iOS App Dev Tutorials

iOS App Dev Tutorials - Passing data - Passing data with bindings Section1. Add a theme view - Step3 ZStack { RoundedRectangle(cornerRadius: 4) .fill(theme.mainColor) Label(theme.name, systemImage: "paintpalette") } ZStack은 하위 뷰를 오버레이하여 두 축에 정렬하는 뷰입니다. Section2. Add a theme picker - Step5 enum Theme: String, CaseIterable, Identifiable { CaseIterable이란, 모든 값의 컬렉션을 제공하는 타입이다. CaseIterable 유형을 사용할 때 유형의 allCases 속성을 사용하여 유형의 모든 사례 모음에 액세스할 수 있습니다. 더보기
iOS App Dev Tutorials - Navigation and modal presentation - Creating the edit view Section3. Display attendees in the edit view - Step2 ForEach(data.attendees) { attendee in Text(attendee.name) } 각 행에 data.attendees를 뿌릴 건데, attendee를 Text(attendee.name)으로 리턴한다. Section3. Display attendees in the edit view - Step3 .onDelete { indices in data.attendees.remove(atOffsets: indices) } 더보기
iOS App Dev Tutorials - Navigation and modal presentation - Managing data flow between views 속성을 @State로 선언하면 보기 내에서 신뢰할 수 있는 원본이 생성됩니다. 시스템은 @State 속성 값에 따라 달라지는 보기의 모든 요소를 ​​식별합니다. 뷰 계층 구조의 다른 뷰에서 동일한 정보 소스를 사용하려면 어떻게 해야 할까요? @Binding으로 래핑하는 속성은 @State 속성과 같은 기존 소스와 읽기 및 쓰기 액세스를 공유합니다. @Binding은 데이터를 직접 저장하지 않습니다. 대신, 기존 정보 소스와 해당 데이터를 표시하고 업데이트하는 보기 사이에 양방향 연결을 생성합니다. 이 연결을 통해 데이터 조각과 연결된 여러 보기가 동기화됩니다. 바인딩을 사용하여 앱의 다른 화면 간에 변경된 상태를 공유합니다. 더보기
iOS App Dev Tutorials - Navigation and modal presentation - Creating a navigation hierarchy Section4. Iterate through attendees - Step4 self.attendees = attendees.map { Attendee(name: $0) } 더보기
iOS App Dev Tutorials - Views - Displaying data in a list Section1. Display a list of daily scrums - Step5 ForEach(scrums, id: \.title) { scrum in } ForEach를 사용하여 일부 데이터 유형의 RandomAccessCollection을 기반으로 뷰를 제공한다. ForEach 구조는 식별 가능한 데이터를 반복하여 동적 보기를 생성합니다. 컬렉션의 요소가 Identifiable을 준수하거나, ForEach 이니셜라이저에 id 매개변수를 제공해야한다. Data와 ID, Content를 구성요소로 가진다. Section2. Make scrums identifiable - Step2 let id: UUID UUID는 타입, 인터페이스 및 기타 항목을 식별하는 보편적으로 고유한 값이다. 더보기
iOS App Dev Tutorials - Views - Creating a card view Section1. Create a color theme - Step6 enum Theme: String { case bubblegum case buttercup . . . var accentColor: Color { switch self { case .bubblegum, .buttercup, .lavender, .orange, .periwinkle, .poppy, .seafoam, .sky, .tan, .teal, .yellow: return .black case .indigo, .magenta, .navy, .oxblood, .purple: return .white } } } Switch문이 사용되었다. Switch문의 기본 형태는 다음과 같다. switch 고려해야 할 값 { case 값1: 값1에 .. 더보기
iOS App Dev Tutorials - SwiftUI essentials - Using stacks to arrange views Section2. Build groups of views - Step3 ProgressView(value: 5, total: 15) ProgressView는 작업완료에 대한 진행 상황을 표시하는 뷰이다. 이니셜라이저로 (value: total:)을 가졌다. 이는 확정된 구체적인 진행 상황을 표시하기 위한 진행률 뷰를 만든다. value 파라미터는 현재 시점까지의 작업의 완료된 양으로, 0.0부터 total까지의 범위를 가진다. total 파라미터는 작업의 전체 범위를 나타내는 양이다. total의 값을 따로 정해주지 않으면, 기본값으로 1.0을 가진다. 그래서 total 값을 따로 설정해주지 않고, value 값을 1이상의 값(예를 들면 5)로 설정하면 항상 진행률이 100%로 나타나게 된다. 그래서 만.. 더보기