๐ฑ iOS
![[UIKit] CustomDatePicker ๋ง๋ค๊ธฐ (2/3)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fdswqvl%2FbtrVIuKWWH7%2FK2M4k2ZMKOZbjkDCTqK8q1%2Fimg.png)
[UIKit] CustomDatePicker ๋ง๋ค๊ธฐ (2/3)
CustomPickerButton์ ๋ง๋ค์์ผ๋ DatePicker๋ก ์งํํด๋ณด์ ์๋ค์ํผ ๋๋ ์ด๊ฑธ ๋ง๋ค๊ธฐ๋ก ํ๋ค ๐ UI setting ๋ณ๊ฑฐ ์๋ค.. ๊ทธ๋ฅ ในใ UI setting code open class CustomDatePicker: UIView{ private var Titlelabel = UILabel() private var years = [String]() private var months = [String]() private var days = [String]() private let yearWidth : CGFloat = 126 private let monthWidth : CGFloat = 103 private let dayWidth : CGFloat = 103 private lazy ..
![[UIKit] CustomDatePicker ๋ง๋ค๊ธฐ (1/3)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbHDMOs%2FbtrVzVKtX8A%2Fu9cNowo06Get3R5Fp0Mf30%2Fimg.jpg)
[UIKit] CustomDatePicker ๋ง๋ค๊ธฐ (1/3)
UIKit ๊ณต๋ถ๊ฒธ ํ๋ก์ ํธ๋ฅผ ์งํํ๋ ๋์ค์ DatePicker๋ฅผ ์ปค์คํ ํด์ผ ํ๋ ์ํฉ๊ณผ ๋ง์ฃผํ๋ค. ๐ ๊ตฌํ๋ด์ฉ ์ผ๋จ ๊ธฐ๋ณธ ์ ๊ณต๋๋ DatePicker๋ฅผ ์ฌ์ฉํ ์๋ ์์๋ค ๊ทธ๋์ UIButton์ inputView์ pickerView๋ฅผ ๋ฃ์ด์ ๋ง๋ค๊ฒ์ด๋ค ์ผ๋ฐ์ ์ผ๋ก TextField์ inputView์ pickerView๋ฅผ ์ฌ์ฉํ๋๋ฐ ๋๋ TextField๊ฐ ํ์์์ด์ ๋์ฅ์ ์ ๊ฑธ์ด๋ณด๊ธฐ๋ก ํ๋ค.. ๐ UI setting ์์ ์ธ๊ธํ๋ CustomDatePicker์์ box ํ๋์ฉ์ CustomPickerButton์ด๋ผ๊ณ ํ๊ฒ ๋ค. // CustomPickerButton.swift public class CustomPickerButton: UIButton { private var uiView = UIV..
![[SwiftUI] @State๋ฅผ ๊ฐ์ง๋ View์ ์
๋ฐ์ดํธ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FIjQdX%2FbtrPP6KD7y9%2FplleNoV1cxDZKhm1SXHbPK%2Fimg.png)
[SwiftUI] @State๋ฅผ ๊ฐ์ง๋ View์ ์ ๋ฐ์ดํธ
์ค๋์ @State์ ๋ํด์ ์กฐ๊ธ ๋ ๊น์ด ์๊ฒ ์์๋ณด๋ ค๊ณ ํด์! ์ผ๋จ @State๊ฐ ์ด๋ค ์ญํ ์ ํ๋์ง ์๋ ๊ฒ์ผ๋ก ๊ฐ์ฃผํ๊ณ ์์ฃผ ๊ฐ๋จํ ์์ ๋ฅผ ๋ณผ๊ฒ์, ๋ชจ๋ฅด๋ฉด ์ด๊ฑฐ ๋ณด๊ณ ์ค๊ธฐ https://990427.tistory.com/64 [SwiftUI] ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ (1/5) @State ๋ฐ์ดํฐ๋ฐ์ธ๋ฉ ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ(data binding)์ ์ ๊ณต์์ ์๋น์๋ก๋ถํฐ ๋ฐ์ดํฐ ์๋ณธ์ ๊ฒฐํฉ์์ผ ์ด๊ฒ๋ค์ ๋๊ธฐํํ๋ ๊ธฐ๋ฒ์ด๋ค. ๋ผ๊ณ ์ํค๋ฐฑ๊ณผ๊ฐ ๋งํ๋๋ฐ, ์ฝ๊ฒ๋งํด SwiftUI์์ ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ์ view 990427.tistory.com ์๋ ์ฝ๋๋ changeItem ๋ฒํผ์ ๋๋ฌ text ๊ฐ์ ๋ณ๊ฒฝ์ํค๋ ์์ ์ ๋๋ค struct ContentView : View { @State var text = "default" va..
![[SwiftUI] NavigationLink์ isActive ๊ณต์ ์ด์ & ํด๊ฒฐ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbbxvK0%2FbtrJ4GwuqkY%2FKVjSwYIPhLibGtzswjWso0%2Fimg.png)
[SwiftUI] NavigationLink์ isActive ๊ณต์ ์ด์ & ํด๊ฒฐ
์ฑ์ ๋ง๋ค๋ค๋ณด๋ฉด List NavigationLink๋ฅผ ๋ง๋ค์ด์ ํด๋น cell์ ํด๋ฆญํ๋ฉด ํ๋ฉด์ด ์ ํ๋๋ ์ฝ๋๋ฅผ ์์ฑํด์ผ ํ ๋๊ฐ ์์ต๋๋ค. ์๋๋ NavigationLink List์ ๊ธฐ๋ณธ์ ์ธ ์ฝ๋ ์ ๋๋ค. @State var list = ["A","B","C"] var body: some View { NavigationView{ List{ ForEach(list, id:\.self){ data in NavigationLink { Text("Page Name: \(data)") // .navigationBarBackButtonHidden(true) } label: { Text("Go \(data)") } } } } } ๋ง์ฝ ์ ํ๋ ํ์ด์ง์ Back๋ฒํผ์ ์์ ๊ณ ์ปค์คํ ํ๊ณ ์ถ์ ๋๋ ์ด๋ป๊ฒ ํด์ผํ ๊น ? ์ฒซ..
![[SwiftUI] TabView ํ์ด์ง ์ด๋์ TabBar , NavigationBar Hidden ์ฒ๋ฆฌํ๊ธฐ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbz0gK6%2FbtrJGVfZASI%2FEZtOStKqysi1xHJEpi0eMK%2Fimg.png)
[SwiftUI] TabView ํ์ด์ง ์ด๋์ TabBar , NavigationBar Hidden ์ฒ๋ฆฌํ๊ธฐ
์ผ์ฃผ์ผ ์ฝ์งํ๊ณ ์์ฑํ๋ ํธ๋ฌ๋ธ์ํ .. ์ฐ์ ๋๋ TabView์์ NavigationView๋ฅผ ๋ด์ ํ์ด์ง ์ด๋์ ํ๊ณ ์ถ์๋ค. FirstView -> SecondView struct ContentView: View { var body: some View { TabView { NavigationView { FirstView() } .tabItem { Text("first") } } } } struct FirstView: View { var body: some View { ZStack{ Color.yellow VStack{ Text("FirstView") NavigationLink { SecondView() } label: { Text("Go SecondView") } } } } } struct Sec..

๋๋ฐ์ด์ค ํ๋ฉด๊ณ ์ portrait only
์ฑ์ ๋ง๋ค๋ ๊ฐ๋กํ๋ฉด์ ๊ณ ๋ คํ์ง ์๊ธฐ ์ํด landscape ๋ชจ๋๋ฅผ ์ง์ํ์ง ์๋ ๋ฐฉ๋ฒ์ ๋๋ค. UIKit๋ก ๊ตฌํํ๋ ๊ฒฝ์ฐ (Storyboard) AppDelegate.swift์ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค. func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return UIInterfaceOrientationMask.portrait } SwiftUI๋ก ๊ตฌํํ๋ ๊ฒฝ์ฐ ๋๋ ํ ๋ฆฌ์ ํ๋ก์ ํธ๋ฅผ ๋๋ฅด๊ณ TARGETS์ ์๋ ํ๋ก์ ํธ๋ฅผ ์ ํํฉ๋๋ค. Info -> Supported interface orientations ์ฌ๊ธฐ์ ์ง์ํ๊ณ ์ ํ..
![[SwiftUI] Grid์์ฑ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdWkvnu%2FbtrGuS1tf4k%2F8WKrNVJNXPKK6gkfMmoQR1%2Fimg.png)
[SwiftUI] Grid์์ฑ
Grid์ ์์ฑ์ ๋ํด์ ์์ธํ ์์๋ณด์. Grid์ ์ข ๋ฅ : LazyHGrid, LazyVGrid ์์ฑ : fixed, flexible, adaptive LazyVGrid ๋ฐ์ดํฐ๋ฅผ ์์ง์ผ๋ก ๋์ดํ๊ณ ์ ํ ๋ ์ฌ์ฉํฉ๋๋ค. ์์ง์ผ๋ก ๋์ดํ๊ธฐ ๋๋ฌธ์ column์ ์ฌ์ฉํฉ๋๋ค. column์ ์ธ๋ก ํ ์ค์ ์๋ฏธํฉ๋๋ค. var body: some View { LazyVGrid(columns: columns) { ForEach(0..

URLSession์ ํตํดJSON ๊ฐ์ ธ์ค๊ธฐ (2)
SwiftUI ์ด ๊ธ์ alamofire์ ๊ฐ์ ์ธ๋ถ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ง ์๋ ์์ฃผ ๊ธฐ์ด์ ์ธ ๋ฐฉ๋ฒ์ ๋๋ค! mockapi.io์์ ์ํ์ ๋ง๋ค๋ฉด ์๋์ ๊ฐ์ ๋ฐ์ดํฐ๋ฅผ ์์ฑํด ์ค๋๋ค. https://62bbeeb36b1401736cecefcf.mockapi.io/user ๋ฐ์ดํฐ๋ ๋ค์๊ณผ ๊ฐ์ด ๊ตฌ์ฑํ์ต๋๋ค. struct User: Codable, Identifiable { var createdAt: String var name: String var avatar: String var id: String } json๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๊ธฐ ์ํด ๋ฉ์ธ์ผ๋ก ์์ฑ๋๋ class๋ ์ด ์ ๊ธ๊ณผ ๋์ผํฉ๋๋ค. ๋๋ณด๊ธฐ class network { func getJSON(completion : @escaping ([User]) ->..

URLSession์ ํตํดJSON ๊ฐ์ ธ์ค๊ธฐ (1)
SwiftUI ์ด ๊ธ์ alamofire์ ๊ฐ์ ์ธ๋ถ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ง ์๋ ์์ฃผ ๊ธฐ์ด์ ์ธ ๋ฐฉ๋ฒ์ ๋๋ค! json data๋ฅผ ๊ฐ์ ธ์ฌ ์ํ๋งํฌ: https://jsonplaceholder.typicode.com/todos ์ ์ฌ์ดํธ์์ ๋ฐ์ json์ ํํ๋ ๋ค์๊ณผ ๊ฐ๋ค. Todo๊ฐ Codable, Identifiable ํ๋กํ ์ฝ์ ์ฑํํด์ผ ํ๋ค. ๊ทธ ์ด์ ๋ ๊ฐ๊ฐ Codable : JSONDecoder()์์ ์ฌ์ฉํ๊ธฐ ์ํจ Identifiable : ๋ฐ์ดํฐ๋ฅผ List์์ ๋ฆฌ์คํ ํ ๋ ์ฌ์ฉํ๊ธฐ ์ํจ struct Todo: Codable, Identifiable { var userId: Int var id: Int var title: String var completed: Bool } network.swift..

Passing Data (์ง์ ์ ๋ฌ๋ฐฉ์)
๋ฐ์ดํฐ๋ฅผ ์ ๋ฌํ๋ ์ฌ์ฏ๊ฐ์ง ๋ฐฉ๋ฒ์ ์์๋ณด์ ! 1. instance property ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌ๋ฐ์ ViewController ํ๋กํผํฐ์ ๊ฐ์ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ์ด๋ค. ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌ๋ฐ์ property๋ฅผ ์ ์ธํ๊ณ , ๊ทธ property์ ๊ฐ์ UI์ ์ ์ฉํ๋ ์๋ฆฌ์ด๋ค. ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌ๋ฐ์ ViewController propertyDataViewController.swift var passingData = "" //์ฌ๊ธฐ์ ๋ฐ์ดํฐ ์ ๋ฌ๋ฐ์ ์์ @IBOutlet weak var setPassingData: UILabel! //์ฌ๊ธฐ์ ์ ๋ฌ๋ฐ์ ๋ฐ์ดํฐ ์ ์ฉ override func viewDidLoad() { super.viewDidLoad() setPassingData.text = passingData } ๋ฐ์ดํฐ๋ฅผ ..