๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“ฑ Mobile/iOS

(24)
[iOS - SwiftUI] ๊ณ„์‚ฐ๊ธฐ ๋งŒ๋“ค๊ธฐ SwiftUI๋กœ ๊ณ„์‚ฐ๊ธฐ ๋งŒ๋“ค๊ธฐ  Button ์‚ฌ์ด์ฆˆ๋ฅผ ์žก์•„์ฃผ๋Š” ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ ๋‹ค. buttonWidth ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” 0 ๋ฒ„ํŠผ์ผ ๊ฒฝ์šฐ์—๋Š” ๋‹ค๋ฅธ ๋ฒ„ํŠผ๋“ค๊ณผ๋Š” ๋‹ค๋ฅด๊ฒŒ ๋„“์€ width๋ฅผ ์ค˜์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋”ฐ๋กœ ์กฐ๊ฑด์„ ๋„ฃ์–ด์ค€๋‹ค.  /// Button Widthfunc buttonWidth(item: CalculatorButton) -> CGFloat { // 0์ผ ๊ฒฝ์šฐ์—๋งŒ ๋„“์€ width๋ฅผ ์ค€๋‹ค! if item == .zero { return ((UIScreen.main.bounds.width - (4 * 12)) / 4) * 2 } return (UIScreen.main.bounds.width - (5 * 12)) / 4}/// Button Heightfunc buttonHeight..
[iOS - HealthKit] HealthKit ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•ด์„œ HealthKit HealthKit์€ Apple์ด iOS ๊ธฐ๊ธฐ์—์„œ ๊ฑด๊ฐ• ๋ฐ ํ”ผํŠธ๋‹ˆ์Šค ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์ง‘ํ•˜๊ณ  ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“  ํ”„๋ ˆ์ž„์›Œํฌ์ด๋‹ค. HealthKit์„ ํ†ตํ•ด ์•ฑ๊ณผ ๊ธฐ๊ธฐ ๊ฐ„์˜ ๋ฐ์ดํ„ฐ ํ†ตํ•ฉ์„ ์šฉ์ดํ•˜๊ฒŒ ํ•˜์—ฌ ์œ ์ €๋“ค์ด ์ž์‹ ์˜ ๊ฑด๊ฐ• ์ •๋ณด๋ฅผ ์ฒด๊ณ„์ ์œผ๋กœ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.  HealthKit ๋ฐ์ดํ„ฐ๋Š” ํฌ๊ฒŒ HKObject๋ฅผ ์ƒ์†๋ฐ›์•„ ๊ตฌํ˜„๋œ๋‹ค. HKSample : ์‹œ์ž‘ ๋ฐ ์ข…๋ฃŒ ์‹œ๊ฐ„๊ณผ ๊ด€๋ จ๋œ HealthKit ์ƒ˜ํ”ŒHKCharacteristic : ์ผ๋ฐ˜์ ์œผ๋กœ ์‹œ๊ฐ„์— ๋”ฐ๋ผ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š๋Š” ๋ฐ์ดํ„ฐHealthKit dataCharacteristic dataCharacteristic data๋Š” ์‚ฌ์šฉ์ž ๊ณ ์œ ์˜ ์‹ ์ฒด์  ํŠน์„ฑ์ด๋‚˜ ๋ณ€ํ•˜์ง€ ์•Š๋Š” ์ •๋ณด๋ฅผ ๊ธฐ๋กํ•˜๋Š” ๋ฐ์ดํ„ฐ์ด๋‹ค. ๋ณดํ†ต ํ•œ ๋ฒˆ ์„ค์ •๋˜๋ฉด ์ž์ฃผ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š๋Š”๋‹ค. ..
[iOS - UIKit] TextField ์ž…๋ ฅ์— ๋”ฐ๋ผ Button ํ™œ์„ฑํ™” ์œ ๋ฌด TextField ์ž…๋ ฅ ์‹œ์ž‘ ์‹œ Button ์ƒํƒœ ๋ณ€๊ฒฝ Button์˜ ํ™œ์„ฑํ™”์™€ UI๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ํ•จ์ˆ˜ Code// textField ์ƒํƒœ์— ๋”ฐ๋ผ LoginButton ์ƒํƒœ ํ™œ์„ฑํ™” ์œ func textFieldDidChangeSelection(_ textField: UITextField) { if (loginView.idTextField.text?.count ?? 0   TextField ์ž…๋ ฅ ์‹œ์ž‘ํ• ๋•Œ ํ…Œ๋‘๋ฆฌ ์ ์šฉ ๋ฐ ํ•ด์ œ   Code// textField๊ฐ€ ํ„ฐ์น˜๊ฐ€ ๋˜๋ฉด ํ…Œ๋‘๋ฆฌ ์„ค์ •func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { textField.layer.borderColor = UIColor.white.cgColor ..
[iOS - UIKit] Keyboard ๋‚ด๋ ค๊ฐ€๊ฒŒ ํ•˜๋Š” ๋ฐฉ๋ฒ• (return ํ‚ค, ์—ฌ๋ฐฑ ๋ˆŒ๋ €์„ ๋•Œ, ๋“œ๋ž˜๊ทธ ๋“ฑ) return ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ํ‚ค๋ณด๋“œ๋ฅผ ๋‚ด๋ฆฌ๋Š” ๋ฐฉ๋ฒ• func textFieldShouldReturn(_ textField: UITextField) -> Bool { if textField == loginView.idTextField { loginView.passwordTextField.becomeFirstResponder() } else { loginView.passwordTextField.resignFirstResponder() } return true}   ์—ฌ๋ฐฑ์„ ๋ˆ„๋ฅด๋ฉด ํ‚ค๋ณด๋“œ๋ฅผ ๋‚ด๋ฆฌ๋Š” ๋ฐฉ๋ฒ•1๋ฒˆoverride func touchesBegan(_ touches: Set, with event: UIEvent?) { view.endEditing(true)}  2๋ฒˆoverride..
[iOS - UIKit] UITextField์— Padding ๊ฐ’ ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• (์ขŒ์šฐ ์—ฌ๋ฐฑ ์ฃผ๊ธฐ) ์‚ฌ์ง„์ฒ˜๋Ÿผ UITextField์—์„œ ์•ˆ์ชฝ์— padding์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.  ์ฝ”๋“œextension UITextField { func addPadding(left: CGFloat? = nil, right: CGFloat? = nil) { if let left { leftView = UIView(frame: CGRect(x: 0, y: 0, width: left, height: 0)) leftViewMode = .always } if let right { rightView = UIView(frame: CGRect(x: 0, y: 0, width: right, height: 0)) rig..
[iOS - Network] iOS์—์„œ ์„œ๋ฒ„ ํ†ต์‹  ํ•˜๋Š” ๋ฐฉ๋ฒ• (URL Session, Alamofire, Moya) ์„œ๋ฒ„ ํ†ต์‹ ์ด๋ž€?๐Ÿ’ก ํด๋ผ์ด์–ธํŠธ(ํ”„๋ก ํŠธ์—”๋“œ)์™€ ์„œ๋ฒ„(๋ฐฑ์—”๋“œ)๊ฐ€ ์„œ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š” ๊ฒƒ  ๊ฐœ์ธ ํ”„๋กœ์ ํŠธ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ๋งŽ์•„๋ดค์ž 10๊ฐœ ์ •๋„์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ค๋ฃจ๊ธฐ ๋•Œ๋ฌธ์— Dummy๋ฅผ ํ™œ์šฉํ•ด์„œ ๋„ฃ์„ ์ˆ˜ ์žˆ์ง€๋งŒ, ๋‚ ์”จ ์•ฑ์„ ์˜ˆ์‹œ๋กœ ๋“ค๋ฉด ์ „๊ตญ์˜ ์ง€์—ญ๋ณ„ ๋‚ ์”จ, ์‹œ๊ฐ„๋Œ€๋ณ„, ๊ฐ•์ˆ˜ํ™•๋ฅ , ์ตœ๊ณ  ์˜จ๋„, ์ตœ์ € ์˜จ๋„ ๋“ฑ๋“ฑ…. ๋„ˆ๋ฌด ๋งŽ์€ ๋ฐ์ดํ„ฐ๋“ค์„ dummy๋กœ ๋‹ค๋ฃจ๋Š” ๊ฑด ๋ถˆ๊ฐ€๋Šฅํ•œ ์ผ์ด๋‹ค. ๋•Œ๋ฌธ์—, ํด๋ผ๋ฆฌ์–ธํŠธ์—์„œ ํ•„์š”ํ•œ ์ •๋ณด๊ฐ€ ์žˆ์„ ๋•Œ๋งˆ๋‹ค ์„œ๋ฒ„์—๊ฒŒ ์š”์ฒญ์„ ํ•˜๊ณ , ์„œ๋ฒ„๋Š” ๊ทธ ์š”์ฒญ์— ๋งž๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „๋‹ฌํ•˜๋Š” ๊ณผ์ •์„ ๊ฑฐ์นœ๋‹ค. ์ด๋ฅผ ์„œ๋ฒ„ ํ†ต์‹ ์ด๋ผ๊ณ  ํ•œ๋‹ค. iOS์—์„œ๋Š” ๋Œ€ํ‘œ์ ์œผ๋กœ URLSession, Alamofire, Moya๋กœ ์„œ๋ฒ„ ํ†ต์‹ ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.URL Session๐Ÿ’ก - Swift์—์„œ๋Š” URLSession์„ ์ด์šฉํ•˜..

728x90