swift

๐Ÿ“‚ News Clipping

iOS 17 ์Šคํฌ๋กค๋ทฐ ๊ฐœ์„ ์‚ฌํ•ญ : ScrollView๋ฅผ ํŽ˜์ด์ง€ ๋‹จ์œ„๋กœ ๋˜๋Š” ์ž์‹ ๋ทฐ ์‚ฌ์ด๋กœ ์Šค๋ƒ…๋˜๊ฒŒ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•

ScrollView๋ฅผ ํŽ˜์ด์ง€ ๋‹จ์œ„๋กœ ๋˜๋Š” ์ž์‹ ๋ทฐ ์‚ฌ์ด๋กœ ์Šค๋ƒ…๋˜๊ฒŒ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ• ์ถœ์ฒ˜ : ํด ํ—ˆ๋“œ์Šจ , 2023๋…„ 6์›” 16์ผ ์ž‘์„ฑ Xcode 15์šฉ์œผ๋กœ ์—…๋ฐ์ดํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. iOS 17์—์„œ์˜ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ SwiftUI์˜ ScrollView๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ์›€์ง์ด์ง€๋งŒ, scrollTargetLayout() ๋ฐ scrollTargetBehavior() ์ˆ˜์ •์ž๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŠน์ • ์ž์‹ ๋ทฐ ๋˜๋Š” ์ „์ฒด ํŽ˜์ด์ง€๋กœ ์ž๋™์œผ๋กœ ์Šค๋ƒ…๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ด ์ฝ”๋“œ๋Š” ๊ฐ€๋กœ ์Šคํฌ๋กค ๋ทฐ์— 10๊ฐœ์˜ ๋‘ฅ๊ทผ ์‚ฌ๊ฐํ˜•์„ ๋ฐฐ์น˜ํ•˜๋ฉฐ ๊ฐ๊ฐ์ด ์Šคํฌ๋กค ํƒ€๊ฒŸ์ธ ๊ฒฝ์šฐ์ž…๋‹ˆ๋‹ค. .scrollTargetBehavior()๊ฐ€ .viewAligned๋กœ ์„ค์ •๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— SwiftUI๋Š” ๋‘ฅ๊ทผ ์‚ฌ๊ฐํ˜• ๊ฐ„์— ์ž๋™์œผ๋กœ ์Šค๋ƒ…๋ฉ๋‹ˆ๋‹ค. struct Conte..

๐ŸŒฑ ์ฝ”๋ฆฐ์ด๋ฅผ ์œ„ํ•œ GUIDE/๐Ÿ—‚๏ธ OpenSource

19 Swift ๋ฐ˜๋ณต๋ฌธ ํ™œ์šฉ, ๋…ผ๋ฆฌ๋ฅผ ๊ตฌ์„ฑํ•˜์—ฌ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

19 ๋ฐ˜๋ณต๋ฌธ ํ™œ์šฉ, ๋…ผ๋ฆฌ๋ฅผ ๊ตฌ์„ฑํ•˜์—ฌ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ ๋ฌธ์ œ ํ’€์ด import UIKit for i in 1...5{ for j in 1...5{ if j

๐ŸŒฑ ์ฝ”๋ฆฐ์ด๋ฅผ ์œ„ํ•œ GUIDE/๐Ÿ—‚๏ธ OpenSource

18 Swift์˜ for ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ๋ฐฐ์ˆ˜ ๊ตฌํ•ด์„œ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

18 for ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ๋ฐฐ์ˆ˜ ๊ตฌํ•ด์„œ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ ๋ฌธ์ œ ํ’€์ด import UIKit for num in 1...100{ if num % 3 == 0{ print("3์˜ ๋ฐฐ์ˆ˜ ๋ฐœ๊ฒฌ : \(num)") } } // continue ํ™œ์šฉ for num in 1...100 { if num % 3 != 0 { continue } print("3์˜ ๋ฐฐ์ˆ˜ ๋ฐœ๊ฒฌ : \(num)") }

๐ŸŒฑ ์ฝ”๋ฆฐ์ด๋ฅผ ์œ„ํ•œ GUIDE/๐Ÿ—‚๏ธ OpenSource

17 Swift์˜ ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ๊ตฌ๊ตฌ๋‹จ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

17 ๊ตฌ๊ตฌ๋‹จ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ ๋ฌธ์ œ ํ’€์ด import UIKit for i in 2...9 { for j in 1...9{ var result = i * j print("\(i) X \(j) = \(result)") } }

๐ŸŒฑ ์ฝ”๋ฆฐ์ด๋ฅผ ์œ„ํ•œ GUIDE/๐Ÿ—‚๏ธ OpenSource

16 Swift๋กœ ๋žœ๋ค๋น™๊ณ  ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ

16 ๋žœ๋ค๋น™๊ณ  ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ ๋ฌธ์ œ ํ’€์ด import UIKit var computer:Int = Int.random(in: 1...10) var user:Int = 5 if computer == user { print("Bingo") } else if computer user { print("Up") }

๐ŸŒฑ ์ฝ”๋ฆฐ์ด๋ฅผ ์œ„ํ•œ GUIDE/๐Ÿ—‚๏ธ OpenSource

15 Swift๋กœ ๊ฐ€์œ„๋ฐ”์œ„๋ณด ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ

15 ๊ฐ€์œ„๋ฐ”์œ„๋ณด ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ ๋ฌธ์ œ ํ’€์ด import UIKit var user:Int = Int.random(in: 0...2) var computer:Int = Int.random(in: 0...2) // 0 : ๋ฐ”์œ„ 1: ๊ฐ€์œ„ 2: ๋ณด //Switch๋ฌธ ์ด์šฉ switch user{ case 0: print("๋‹น์‹ ์€ ๋ฐ”์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") case 1: print("๋‹น์‹ ์€ ๊ฐ€์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค") case 2: print("๋‹น์‹ ์€ ๋ณด๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") default: break } switch computer{ case 0: print("์ปดํ“จํ„ฐ๋Š” ๋ฐ”์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") case 1: print("์ปดํ“จํ„ฐ๋Š” ๊ฐ€์œ„๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") case 2: print("์ปดํ“จํ„ฐ๋Š” ๋ณด๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.") default: break } /..

์–‘์ฝฉ(Yangkong)
'swift' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก