SwiftUI - Sticky Header
ยท
iOS/SwiftUI
์•ˆ๋…•ํ•˜์„ธ์š” :D ๋ง๊ณ ์ž…๋‹ˆ๋‹ค๐Ÿฅญ SwiftUI๋กœ Sticky Header ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Sticky Header๋ž€? ์‚ฌ์šฉ์ž๊ฐ€ ํ™”๋ฉด์„ ์•„๋ž˜๋กœ ์Šคํฌ๋กค ํ•  ๋•Œ ํ™”๋ฉด ์ƒ๋‹จ์— ๊ณ ์ •๋˜๋Š” ๋ทฐ๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค. ์ฒ˜์Œ์—” Sticky Header๋ผ๋Š” ์šฉ์–ด๋ฅผ ๋ชฐ๋ผ์„œ ํ•œ์ฐธ ์ฐพ์•„๋ด„ ใ… ใ…  LazyVStack์˜ pinnedViews๋ผ๋Š” ์˜ต์…˜์„ ํ†ตํ•ด ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. [.sectionHeaders]๋ฅผ ํ†ตํ•ด ์ƒ๋‹จ์— ๊ณ ์ •์‹œํ‚ค๋„๋ก ์„ค์ •ํ–ˆ๊ณ , post, liked ๋ถ€๋ถ„์„ filterBar๋กœ ๊ตฌํ˜„ ํ•œ ๋‹ค์Œ Section(header: filterBar)์— ๋„ฃ์–ด์ฃผ์—ˆ๋‹ค. private var StickyHeader: some View { LazyVStack(pinnedViews: [.sectionHeaders]) { Section(..
SwiftUI - System Icons
ยท
iOS/SwiftUI
์•ˆ๋…•ํ•˜์„ธ์š” :D ๋ง๊ณ ์ž…๋‹ˆ๋‹ค๐Ÿฅญ SwiftUI์˜ System Icons์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. System Icons Apple์—์„œ ๊ธฐ๋ณธ ์ œ๊ณต๋˜๋Š” ์•„์ด์ฝ˜๋“ค์ด๋‹ค. ๊ธฐ๋ณธ์ ์ธ ์‚ฌ์šฉ ๋ฐฉ๋ฒ• Image(systemName: "์•„์ด์ฝ˜ ์ด๋ฆ„") Image(systemName: "heart") //๋นˆ ์•„์ด์ฝ˜ Image(systemName: "heart.fill") //์ฑ„์›Œ์ง„ ์•„์ด์ฝ˜ ์ด๋Ÿฐ์‹์œผ๋กœ systemName: ์•„์ด์ฝ˜ ์ด๋ฆ„์„ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ์•„์ด์ฝ˜ ์ด๋ฆ„์€ https://developer.apple.com/sf-symbols/์„ ๋‹ค์šด ๋ฐ›์œผ๋ฉด ํŽธํ•˜๊ฒŒ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์˜ต์…˜๋“ค .font(.system(size: 36)) // ํฌ๊ธฐ๋ณ€๊ฒฝ .foregroundColor(.red) // ์ƒ‰์ƒ๋ณ€๊ฒฝ .resizable() .scaledToFi..
SwiftUI - Navigation dismiss
ยท
iOS/SwiftUI
์•ˆ๋…•ํ•˜์„ธ์š” :D ๋ง๊ณ ์ž…๋‹ˆ๋‹ค๐Ÿฅญ SwiftUI์˜ Navigation dismiss์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. iOS 15.0+ private struct SheetContents: View { @Environment(\.dismiss) private var dismiss // ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ ์–ธ var body: some View { Button("Done") { dismiss() // ์‚ฌ์šฉ } } } ๋จผ์ € ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•ด์ค€๋‹ค์Œ dismiss() ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.
SwiftUI - Color
ยท
iOS/SwiftUI
์•ˆ๋…•ํ•˜์„ธ์š” :D ๋ง๊ณ ์ž…๋‹ˆ๋‹ค๐Ÿฅญ SwiftUI์˜ Color์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Color Color.์ƒ‰์ƒ์„ ํ•ด์ฃผ๊ฒŒ ๋˜๋ฉด ์›ํ•˜๋Š” ์ƒ‰์œผ๋กœ ๋ณ€๊ฒฝ๋ฉ๋‹ˆ๋‹ค. Color.์ƒ‰์ƒ ex) Color.red ๊ธฐ๋ณธ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ƒ‰์ƒ extension Color { public static let red: Color public static let orange: Color public static let yellow: Color public static let green: Color @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public static let mint: Color @available(iOS 15.0, macOS 12.0, tvOS 15.0,..