본문 바로가기

swiftUI7

SwiftUI Tutorial 8 - Interfacing with UIKit 1. Create a view to represent a UIPageViewControllerUIViewControllerRepresentable 프로토콜을 준수하는 구조체를 만든다.UIViewControllerRepresentable이 요구하는 메서드를 구현한다.SwiftUI 는 뷰를 보여줄 준비가 되었을 때 makeUIViewController(context:)를 호출하고updateUIViewController는 해당 뷰 컨트롤러가 업데이트되어야 할 때마다 호출한다.import SwiftUIimport UIKitstruct PageViewController: UIViewControllerRepresentable { var pages: [Page] func makeUIViewControlle.. 2024. 7. 10.
SwiftUI Tutorial 7 - Composing complex interfaces 1. Add a category viewimport SwiftUIstruct CategoryHome: View { var body: some View { NavigationSplitView { Text("Hello, World!") .navigationTitle("Featured") } detail: { Text("Select a Landmark") } }} 2. Create a category listLandmark 구조체에 Category enum과 프로퍼티를 추가한다. struct Landmark: Hashable, Codable, Identifiable { var id: Int .. 2024. 7. 9.
SwiftUI Tutorial 6 - Animating views and transitions 1. Add hiking data to the app제공하는 json 데이터 파일을 프로젝트에 다운 받은 다음 데이터 양식에 맞게 구조체를 구현한다.struct Hike: Codable, Hashable, Identifiable { var id: Int var name: String var distance: Double var difficulty: Int var observations: [Observation] static var formatter = LengthFormatter() var distanceText: String { Hike.formatter .string(fromValue: distance, unit: .kilomete.. 2024. 7. 8.
SwiftUI Tutorial 5- Drawing paths and shapes 1. Create drawing data for a badge viewimport CoreGraphicsstruct HexagonParameters { struct Segment { let line: CGPoint let curve: CGPoint let control: CGPoint } static let adjustment: CGFloat = 0.085 static let segments = [ Segment( line: CGPoint(x: 0.60, y: 0.05), curve: CGPoint(x: 0.40, y: 0.05), control: CGPoint(x:.. 2024. 7. 7.
SwiftUI Tutorial 4 - Handling user input 1. Mark favorite landmarks모델 클래스에 isFavorite 프로퍼티를 추가한다.struct Landmark: Hashable, Codable, Identifiable { var id: Int var name: String var park: String var state: String var description: String var isFavorite: Bool private var imageName: String var image: Image { Image (imageName) } private var coordinates: Coordinates var locationCoordinate: CLLo.. 2024. 7. 6.
SwiftUI Tutorial 2 - Creating and combining views 1 1. Create a new project and explore the canvasSwiftUI 튜토리얼 진행 시 macOS Sonoma 이상이어야 문제없이 진행 가능 튜토리얼대로 프로젝트를 생성 후 보게 되는 파일.@main 속성은 앱의 진입 포인트를 의미한다고 한다.  Preview 기능도 있다. 역시 보면서 해야 맘이 편하다.. 2. Customize the text view source editor, canvas, inspectors 의 조합으로 코딩. 우선 Inspector 를 써보자 캔버스 화면 아래 마우스 커서 버튼을 누른 후 Command + Control 과 함께 클릭하면 아래 창이 뜬다. 그 중에 Show SwiftUI Inspector 클릭  이곳에서 수정하면 바로 관련된 코드가 추가.. 2024. 7. 3.
SwiftUI Tutorial 1 - SwiftUI overview 애플 개발자 문서에서 SwiftUI Tutorial 을 시작하기 전에 정리해놓은 SwftUI의 개요 4가지 - Declarative syntax—Define which views appear onscreen using simple Swift structures. Flutter, React 와 같이 최근 프론트엔드 프레임워크들 사이에서 자주 채용되는 방식인 '선언적 구문'을 통한 프로그래밍  A compositional API—Quickly create and iterate your user interface using built-in views and modifiers. Compose more complex views by combining simpler views. compositional 이란 단어의.. 2024. 7. 2.