๐Ÿ“ฑ iOS

    [UIKit] CustomDatePicker ๋งŒ๋“ค๊ธฐ (2/3)

    [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)

    [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์˜ ์—…๋ฐ์ดํŠธ

    [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 ๊ณต์œ  ์ด์Šˆ & ํ•ด๊ฒฐ

    [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 ์ฒ˜๋ฆฌํ•˜๊ธฐ

    [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

    ๋””๋ฐ”์ด์Šค ํ™”๋ฉด๊ณ ์ • 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์†์„ฑ

    [SwiftUI] Grid์†์„ฑ

    Grid์˜ ์†์„ฑ์— ๋Œ€ํ•ด์„œ ์ž์„ธํžˆ ์•Œ์•„๋ณด์ž. Grid์˜ ์ข…๋ฅ˜ : LazyHGrid, LazyVGrid ์†์„ฑ : fixed, flexible, adaptive LazyVGrid ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์ง์œผ๋กœ ๋‚˜์—ดํ•˜๊ณ ์ž ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ˆ˜์ง์œผ๋กœ ๋‚˜์—ดํ•˜๊ธฐ ๋•Œ๋ฌธ์— column์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. column์€ ์„ธ๋กœ ํ•œ ์ค„์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. var body: some View { LazyVGrid(columns: columns) { ForEach(0..

    URLSession์„ ํ†ตํ•ดJSON ๊ฐ€์ ธ์˜ค๊ธฐ (2)

    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)

    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 (์ง์ ‘์ „๋‹ฌ๋ฐฉ์‹)

    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 } ๋ฐ์ดํ„ฐ๋ฅผ ..