ํฐ์คํ ๋ฆฌ ๋ทฐ
์์ฑํ App ๊ตฌ์กฐ์ฒด
import SwiftUI
@main
struct LandMarksApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
- @Main → ๊ตฌ์กฐ์ฒด ์ ์ธ ์์ @main ํน์ฑ์ ๋ถ์ฌ ์ฑ์ ์ง์ ์ ์ ๋ํ๋ ๋๋ค. ์ฑ์ ํ๋์ ์ง์ ์ ๋ง ๊ฐ์ง๋๋ค.
- App protocol: ์ฑ์ ๊ตฌ์กฐ์ ๋์์ ๋ํ๋ด๋ ์ ํ์ ๋๋ค.
→ ์ฑ ์์์ ContentView๋ฅผ ๋์ฐ๊ฒ ๋ค๋ ์๋ฏธ
ContentView
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
MapView
import SwiftUI
import MapKit
struct MapView: View {
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 34.011, longitude: -116.166),
span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)
)
var body: some View {
Map(coordinateRegion: $region)
}
}
struct MapView_Previews: PreviewProvider {
static var previews: some View {
MapView()
}
}
1. @State - ๋ทฐ๋ฅผ ์ ๋ฐ์ดํธํ ์ ์๋ ๋ณ์
2. ๋ณ์์์ $ ์ง์ ํ๋ฉด,@State ๋ณ์๊ฐ ์ ๋ฐ์ดํธ๋ ๋ ๋ง๋ค ๋ฐ์ธ๋ฉ
Image ๋ฃ๊ณ ContentMode ์ ์ฉํ๋ ๋ฐฉ๋ฒ
์์๊ฐ ์ค์
- resizeable() - ํ๋ฉด ํฌ๊ธฐ์ ๋ง์ถ์ด ์ฑ์์ค
- aspectRatio(contentMode: .fit) - frame ์ด์ ์ contentMode์ ์ฉ
- ์ดํ frame ํฌ๊ธฐ ๋ง์ถฐ์ฃผ๊ธฐ
- .frame(width: 200, height: 230)๊ทธ๋ค์ clip to bouns ์ ์ฉ .clipShape(Circle()) ๋๋ .clipShape(RoundedRectangle(cornerSize: .init(width: 40, height: 40)))
import SwiftUI
struct CircleImage: View {
var body: some View {
VStack {
Image("test")
.aspectRatio(contentMode: .fill)
.frame(width: 200, height: 200)
.clipShape(Circle())
.overlay {
Circle().stroke(.white, lineWidth: 3)
}
.shadow(radius: 5)
}
}
}
struct CircleImage_Previews: PreviewProvider {
static var previews: some View {
CircleImage()
}
}
List ๋ง๋ค๊ธฐ
import SwiftUI
struct LandmarkList: View {
var body: some View {
List(landmarks, id: \.id) { landmark in
LandmarkRow(landmark: landmark)
}
}
}
struct LandmarkList_Previews: PreviewProvider {
static var previews: some View {
LandmarkList()
}
}
+ Data ๊ตฌ์กฐ์ฒด์ Hashable ํ๋กํ ์ฝ ์ถ๊ฐ
import Foundation
import SwiftUI
import CoreLocation
struct 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 {
Image(imageName)
}
private var coordinates: Coordinates
var locationCoordinate: CLLocationCoordinate2D {
CLLocationCoordinate2D(
latitude: coordinates.latitude,
longitude: coordinates.longitude)
}
struct Coordinates: Hashable, Codable {
var latitude: Double
var longitude: Double
}
}
List ๋ง๋ค๊ธฐ2 (๋ ๊ฐ๊ฒฐํ๊ฒ)
import Foundation
import SwiftUI
import CoreLocation
struct Landmark: Hashable, Codable, Identifiable {
var id: Int
var name: String
var park: String
var state: String
var description: String
...
}
Identifiable ํ๋กํ ์ฝ ์ถ๊ฐํ๋ฉด
import SwiftUI
struct LandmarkList: View {
var body: some View {
List(landmarks) { landmark in
LandmarkRow(landmark: landmark)
}
}
}
struct LandmarkList_Previews: PreviewProvider {
static var previews: some View {
LandmarkList()
}
}
์ด๋ฐ์์ผ๋ก id: \.id ์์ด ๊ฐ๊ฒฐํ๊ฒ ์ฒ๋ฆฌ ๊ฐ๋ฅ
๋๊ธ
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- swift urlcomponent encode
- swift ๋คํธ์ํฌ ๋ชจ๋ํ
- swift ์์ ๊ฐ์ ธ์ค๊ธฐ
- llm pdf rag
- swift network refactoring
- ์๋์ํํธ ๋ ์ด์ธ์ด
- chatgpt rag llm
- readysay
- ๋ ๋์ธ์ด
- swift urlsession network module
- swift ์๊ฐ
- swift get excel
- focus timer ์ดํ
- swift urlsession ๊ณตํตํ
- llm csv
- swift excel read
- swift network module
- swift network ๊ณตํตํ
- swift urlsession refactoring
- swift ์์ ์ฝ๊ธฐ
- rag ๊ธฐ๋ฐ llm ์ฑ๋ด
- swift queryitem encode
- filemanager excel read
- ๋ ๋์ธ์ด ์ดํ
- rag llm pdf
- swift filemanager excel
- ๊ณต๋ถ ํ์ด๋จธ ์ดํ
- swift filemanager get excel
- swift urlsession module
- rag ๊ธฐ๋ฐ llm
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
๊ธ ๋ณด๊ดํจ