본문 바로가기

iOS/SwiftUI Tutorial4

SwiftUI Tutorial 3 - Building lists and navigation 1. Create a landmark model먼저 튜토리얼 페이지에서 제공하는 데이터 파일들을 프로젝트에 다운 받은 후 데이터를 담을 구조체를 만든다.연산 프로퍼티인 image 와 locationCoordinate도 추후에 용이하게 써먹기 위해 만들어 놓는다.import Foundationimport SwiftUIimport CoreLocationstruct Landmark: Hashable, Codable { var id: Int var name: String var park: String var state: String var description: String private var imageName: String var image: Image { .. 2024. 7. 5.
SwiftUI Tutorial 2 - Creating and combining views 2 5. Use SwiftUi viewx from other frameworksMapKit 을 import 해서 Map 뷰를 써본다.6. Compose the detail view이제 custom한 뷰들을 조합한다. 눈에 띄는 것이 두가지. 첫째, Vstack(Hstack) 안에서 offset과 padding을 통해 다른 뷰의 영역 위로 이동할 수 있다. CircleImage가 MapView 위를 지나가는 것을 볼 수 있다.괜히 Stack 이라는 단어를 쓴 것이 아니었구나. 추측컨데 아래의 선언된 것이 위를 차지하는 듯하다. 둘째, 공통 속성일 경우 상위의 view 에서 속성을 지정할 수 있다. Text 뷰가 두개가 있지만 상위 뷰인 HStack에서 font와 foregroundStyle 속성을 선언할 수 .. 2024. 7. 4.
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.