๐Ÿ“ฑ iOS/UIKit

    modalPresentationStyle ์„ค์ • ์‹œ์ (feat.ViewLifeCycle)

    modalPresentationStyle ์„ค์ • ์‹œ์ (feat.ViewLifeCycle)

    ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ์—์„œ ํˆฌ๋ช…ํ•œ ViewController๋ฅผ ๋„์šธ ์ผ์ด ์ƒ๊ฒผ๋Š”๋ฐ, `modalPresentationStyle = .overFullScreen` ์„ viewDidLoad() ์‹œ์ ์— ์ž‘์„ฑํ–ˆ๋”๋‹ˆ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค.    viewDidLoad()๋Š” present() ์ดํ›„์— ํ˜ธ์ถœ๋˜์–ด View๋ฅผ ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œํ•˜๋Š”๋ฐ,์•„๋งˆ present()ํ•˜๋Š” ๋‹น์‹œ์— ์ƒˆ๋กœ์šดVC๊ฐ€ ๊ฐ€์ง„ modalStyle์„ ์ ์šฉํ•˜๋Š” ๋“ฏ ํ•˜๋‹ค.present ์—๋‹ˆ๋ฉ”์ด์…˜ ์ ์šฉํ•˜๋ ค๋ฉด ๊ทธ๋ž˜์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค..  ๊ทธ๋ž˜์„œ presentํ•˜๊ธฐ ์ „์— modalStyle์„ ๋ณ€๊ฒฝํ•ด์ฃผ์–ด์•ผ ํ•˜๋Š”๋ฐ, ๋ณดํ†ต์€ presentํ•˜๋Š” VC์—์„œ ์„ค์ •ํ•ด์ฃผ์ง€๋งŒ,์™ธ๋ถ€์—์„œ ํ•ด๋‹น ViewController๋ฅผ ์ปจํŠธ๋กคํ•˜์ง€ ์•Š๋„๋ก ํ•˜๊ธฐ ์œ„ํ•ด init()์‹œ์ ์— modalStyle์„ ์ ์šฉ..

    [UIKit] TableView Multiple Cell, multi type json data parsing

    [UIKit] TableView Multiple Cell, multi type json data parsing

    TableView๋Š” ํ•˜๋‚˜์˜ Cell์ด ์•„๋‹Œ ๋‹ค์–‘ํ•œ Cell์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.์ข…์ข… ์•ฑ์„ ๋ณด๋‹ค๋ณด๋ฉด tableview ์ค‘๊ฐ„์ค‘๊ฐ„ ๊ด‘๊ณ ๊ฐ€ ๋‚˜์˜จ๋‹ค๊ฑฐ๋‚˜, ๋‚˜๋ฅผ ์œ„ํ•œ ์ถ”์ฒœ์„ ํ•œ๋‹ค๊ฑฐ๋‚˜ ...๋Œ€๋ถ€๋ถ„์˜ ์•ฑ ์„œ๋น„์Šค๊ฐ€ tableview๋ฅผ ์‚ฌ์šฉํ•˜๊ณ , multiple cell์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.๊ทธ๋ž˜์„œ ์ €๋„ multiple cell์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์•ฑ์„ ๋งŒ๋“ค์–ด ๋ณผ๊ฒƒ์ž…๋‹ˆ๋‹ค! ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ๋จผ์ € ๋ฉ€ํ‹ฐํƒ€์ž… ๋ฐ์ดํ„ฐ๋ฅผ ์–ด๋–ป๊ฒŒ ๊ฐ€์ ธ์˜ฌ ๊ฒƒ์ธ์ง€์— ๋Œ€ํ•ด ๊ณ ๋ฏผํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.(JSON์— ๋Œ€ํ•œ ๋‚ด์šฉ์€ ์ ‘์€๊ธ€์— ์žˆ์Šต๋‹ˆ๋‹ค)๋”๋ณด๊ธฐlet JSONData ="""{ "data" : [ { "type" : "TITLE_ONLY", "title" : "Struct vs Class" }, ..

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

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

    Rx๋ฅผ ๋ชจ๋ฅด์‹ ๋‹ค๋ฉด ์ดํ•ดํ•˜๊ธฐ ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค ๐Ÿฅน ๋“œ๋””์–ด ๋งˆ์ง€๋ง‰ ๊ด€๋ฌธ.. ๋…„,์›”์„ ๊ด€์ฐฐํ•˜์—ฌ ์ผ ์ˆ˜๋ฅผ ์ •ํ•˜์ž! ์ผ๋‹จ ๋‚˜๋Š” ์ง€๊ธˆ ์ด๊ฑธ ๋งŒ๋“œ๋Š” ์ค‘์ด๋‹ค ๋…„,์›”์€ ์˜์กด์„ฑ์ด ์—†์ง€๋งŒ, '์ผ'์€ ๋…„,์›”์— ์˜์กด์„ฑ์„ ๊ฐ€์ง€๊ฒŒ ๋œ๋‹ค. 1์›”์€ 31์ผ๊นŒ์ง€, 2์›”์€ 28์ผ๊นŒ์ง€ ๋ญ์ด๋Ÿฐ๊ฑฐ ~.. ๊ทธ๋ž˜์„œ '์ผ'์€ ๋…„,์›”์ด ๋ฐ”๋€Œ๋ฉด reset์„ ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. ์˜ˆ๋ฅผ๋“ค์–ด 2023๋…„1์›”31์ผ์„ ๋งŒ๋“ค์–ด์ค€ ์ƒํƒœ์—์„œ '์›”'์„ 2์›”๋กœ ๋ฐ”๊พธ๋ฉด 31์ผ์€ ์—†๊ธฐ ๋•Œ๋ฌธ์—!! ๊ทธ๋ž˜์„œ customPicker์—์„œ ๋ญ”๊ฐ€๋ฅผ ์„ ํƒํ–ˆ์„ ๋•Œ ๊ด€์ฐฐํ•˜๋Š” ๋Œ€์ƒ์—๊ฒŒ ์•Œ๋ ค์ค„ ์ˆ˜ ์žˆ๋„๋ก Rx๋ฅผ ์ถ”๊ฐ€์ ์œผ๋กœ ์ ์šฉํ–ˆ๋‹ค. (1/3)์—์„œ ๋งŒ๋“ค์—ˆ๋˜ CustomPickerButton์— ์ถ”๊ฐ€ํ•œ ๋ถ€๋ถ„! public class CustomPickerButton: UIButton { var change..

    [UIKit] toast message ๋งŒ๋“ค๊ธฐ

    [UIKit] toast message ๋งŒ๋“ค๊ธฐ

    ์•ฑ์„ ๋งŒ๋“ค๋‹ค๋ณด๋ฉด toast msg๋ฅผ ๋„์›Œ์„œ ์ •๋ณด๋ฅผ ์ฃผ๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์€๋ฐ ์•„์‰ฝ๊ฒŒ๋„ iOS์—๋Š” ๊ทธ๋Ÿฐ ๊ธฐ๋Šฅ์ด ์—†๋‹ค.. ์ง์ ‘ ๋งŒ๋“ค์ž! ์šฐ์„  UIView๋ฅผ ์ƒ์†ํ•˜๋Š” class๋ฅผ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค public class ToastMessage: UIView {} ์ €๋Š” ์š”๋ก  ์ข…๋ฅ˜์˜ ํ† ์ŠคํŠธ ๋ฉ”์„ธ์ง€๋ฅผ ๋งŒ๋“ค๊ฑฐ์—์š” (x๋Š” ์ œ์™ธ) ๊ทธ๋ž˜์„œ ์ด๋Ÿฐ ํ”„๋กœํผํ‹ฐ์™€ enum์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค public enum ToastType { case common, alert, info } var text = UILabel() var icon = UIImageView() var type : ToastType UI๋Š” ๊ฐ์ž ์ทจํ–ฅ๊ป ๋งŒ๋“œ์‹œ๊ณ  (์ƒ๋žต) ํ† ์ŠคํŠธ ๋ฉ”์„ธ์ง€์˜ ํŠน์ง•์€ ์ž ๊น ๋–ด๋‹ค ์‚ฌ๋ผ์ง€๋Š”๊ฑฐ ์ž–์•„์š” ? ๊ทธ ๋ถ€๋ถ„์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด animate๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค an..

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

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