์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 31 |
- visionOS
- SwiftUI
- raywenderlich
- CollectionView
- Kuring
- TCA
- tableView
- rxcocoa
- realm
- UIKit
- ํจ์คํธ์บ ํผ์ค
- designpattern
- SnapKit
- Swfit
- XCTest
- BFS
- swift
- ios
- combine
- BOJ
- ๋ฐฑ์ค
- MVVM
- Xcode
- node.js
- Lv2
- arkit
- RxSwift
- ํ๋ก๊ทธ๋๋จธ์ค
- Flutter
- reactorkit
- Today
- Total
๋ชฉ๋กapple/๐ SwiftUI & Combine (26)
lgvv98
@StateObject โ ์๋ ๊ณต์๋ฌธ์๋ฅผ ๋ฐํ์ผ๋ก ์์ฑํ์์ต๋๋ค. https://developer.apple.com/documentation/swiftui/stateobject Apple Developer Documentation developer.apple.com ํน์ฑ ์ ์ธ์ @StateObject ์์ฑ์ ์ ์ฉํ๊ณ ObservableObject ํ๋กํ ์ฝ์ ์ค์ํ๋ ์ด๊ธฐ ๊ฐ์ ์ ๊ณตํ์ฌ View, App ๋๋ Scene์์ ์ํ ๊ฐ์ฒด๋ฅผ ๋ง๋ญ๋๋ค. @StateObject var model = DataModel() SwiftUI์์๋ ๊ฐ์ฒด๋ฅผ ์ ์ธํ๋ ์ธ์คํด์ค์ ๋ํด ํ ๋ฒ๋ง ๊ฐ์ฒด์ ์ ์ธ์คํด์ค๋ฅผ ์์ฑํฉ๋๋ค. ๊ด์ฐฐ ๊ฐ๋ฅํ ๊ฐ์ฒด์ ์์ฑ์ด ๋ณ๊ฒฝ๋๋ฉด SwiftUI๋ ํด๋น ์์ฑ์ ์์กดํ๋ ๋ทฐ์ ์ผ๋ถ๋ฅผ ์ ๋ฐ์ดํธํฉ๋๋ค...
State and Data Flow โ ์๋์ ๋ฌธ์ ์ค ํ์ํ ๋ถ๋ถ์ ๊ณจ๋ผ์ ์์ฑํ์์ต๋๋ค. https://developer.apple.com/documentation/swiftui/state-and-data-flow Apple Developer Documentation developer.apple.com SwiftUI๋ user interface ๋์์ธ์ ์ ์ธ์ ์ผ๋ก ์ ๊ณตํ๊ณ ์๋ค. (์ ์ธํ ํ๋ก๊ทธ๋๋ฐ) ๋ฐ๋ผ์ view๋ฅผ ๊ณ์ธต์ ์ผ๋ก ๊ตฌ์ฑํ ๋ views๋ฅผ ์ํ ๋ฐ์ดํฐ๋ ์ข ์์ฑ๋ ํ์ํ๋ค. ์ธ๋ถ ์ด๋ฒคํธ ํน์ user๊ฐ ์ทจํ๋ ์ก์ ์ ์ํด ๋ฐ์ดํฐ์ ๋ณํ๊ฐ ์์ ๋, SwiftUI์ ์ํฅ์ ๋ฐ๋ ๋ถ๋ถ์ ์๋์ผ๋ก ์ ๋ฐ์ดํธ ํฉ๋๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก ์ด ํ๋ ์์ํฌ(SwiftUI)๋ ์ ํต์ ์ผ๋ก viewController์..
ํ๋ฉด ์คํฌ๋ฆฐ์ท ๋ฐ ๋ นํ ๊ฐ์ง โ ํ๋ฉด ๋ นํ ๋ฐ ์คํฌ๋ฆฐ์ท ๊ฐ์ง์ ๋ํด์ ์์๋ด ์๋ค. ์ฐ์ ํ๋ฉด ๋ นํ ๋ฐ ์คํฌ๋ฆฐ์ท์ NotificationCenter๋ฅผ ํตํด ์ ์ ์์ต๋๋ค. // ํ๋ฉด์บก์ณ NotificationCenter.default.publisher(for: UIScreen.capturedDidChangeNotification) // ํ๋ฉด๋ นํ NotificationCenter.default.publisher(for: UIApplication.userDidTakeScreenshotNotification) โ ์ฝ๋ import SwiftUI struct ContentView: View { var body: some View { ZStack { MainView() // ๋ฉ์ธ ์ปจํ ํธ ๋ทฐ BlockView() ..
ViewModifier โ ๊ณต์๋ฌธ์ https://developer.apple.com/documentation/swiftui/viewmodifier Apple Developer Documentation developer.apple.com โ ๊ณต์๋ฌธ์์ ์ผ๋ถ โ ์ด๋ฅผ ํตํด์ ์ค๋ณต๋๋ ์ฝ๋๋ฅผ ์ฝ๊ฒ ์ค์ผ ์ ์์ต๋๋ค. import SwiftUI struct ContentView: View { var body: some View { VStack(spacing: 50){ Text("Hello, world!") .modifier(MyRoundedText()) // modifier๋ฅผ ํ์ฉ Text("Hello, world!") .myRoundedTextStyle() Image(systemName: "pencil") ..
lazyVGrid โ swiftUI ์์ง๋ ๋ค๋ฃจ๋๊ฒ ์ด๋ ค์ด ๊ฒ ๊ฐ๋ค. UIKit์ด์๋ค๋ฉด ๋ฑ ๋์ด์ผ ํ๋๊ฑด๋ฐ, ์ ์๋์ง ํ๋๊ฑธ ๋ณด๋๊น ์๋ จ๋๊ฐ ๋ฎ์ ๊ฒ ๊ฐ์์ ๊ฐ์๊ธฐ ์ฌํ๋ค ใ ใ ๋ ๋๋์ ์ธ๋ฐ ์ค์ ๊ฐ ๋๋ฑ๋๋ฑ ์ฒ์์ ํ 80ํ๋ก๊น์ง๋ ๋นจ๋ฆฌ ๋ง๋๋๋ฐ ๊ฒฐ๊ตญ์ UIKit ๋ถ๋ถ์ ์ฌ์ฉํด์ผ ํ๋ ์์ ์์๋ ์์ด ๋ง์ด๊ฐ๊ธฐ ์์ํด์, ํ ,, โ ์ฝ๋ import Foundation import SwiftUI enum LayoutType: CaseIterable { case table, grid, multiple } extension LayoutType { // ๋ ์ด์์ ํ์ ์ ๋ํ ์ปฌ๋ผ์ด ์๋์ผ๋ก ์ค์ ๋๋๋ก ํ๋ค var columns : [GridItem] { switch self { case .table: retu..
menu (feat. Picker) โ ๋ฉ๋ด์ ๋ํด์ ์์๋ณด์. ์คํ ๋ฆฌ๋ณด๋๋ฅผ ์ ์ฌ์ฉ์ํ๋๋ฐ, ์ด๋๋ ๋ณด๋๊น menu๋ฅผ ์ฌ์ฉํ ์ ์๋ ๋ฒํผ์ด ๋ค์ด์๋ค. โ ์ฝ๋ import SwiftUI let myPets = ["๋ฉ๋ฉ์ด ๐ถ", "์ผ์น์ด ๐ฏ", "์ฐ์ฐ์ด ๐น"] struct ContentView: View { @State private var shouldShowAlert : Bool = false // alert๋ฅผ ๋์ฐ๊ธฐ ์ํจ. @State private var myText : String = "" // ํ ์คํธ @State private var selected : Int = 0 // ์ ํํ ์ธ๋ฑ์ค var body: some View { NavigationView { // Spacer()๋ ์๋จ 1 ํ๋จ ..