Definition @resultBuilder struct ViewBuilder ํด๋ก์ ์์ ๋ทฐ๋ฅผ ๊ตฌ์ฑํ๋ ์ฌ์ฉ์ ์ง์ ํ๋ผ๋ฏธํฐ ์์ฑ func contextMenu( @ViewBuilder menuItems: () -> MenuItems ) -> some View ํด๋ก์ ํ๋ผ๋ฏธํฐ๋ฅผ ํตํด child view๋ฅผ ์์ฑํ๊ณ ์ ํ ๋ ViewBuilder๋ฅผ ์ฌ์ฉํ ์ ์๋ค. ์์ ๊ฐ์ด ํ๋ผ๋ฏธํฐ๋ก ViewBuilder๋ฅผ ์ฌ์ฉํด ํด๋ก์ ๋ก child view๋ฅผ ํฌํจํ๋ ๋ทฐ๋ฅผ ์์ฑํ ์ ์๋ค. myView.contextMenu { Text("Cut") Text("Copy") Text("Paste") if isSymbol { Text("Jump to Definition") } } contextMenu์ menuItems ํด..
ํฐํธ๋ ํ๋ฆฌํ
๋ค๋ ์ฌ์ฉํจ (์ฌ์ดํธ๋งํฌ) Pretendard Pretendard ํ๋ฆฌํ
๋ค๋ Pretendard ํ๋ฆฌํ
๋ค๋ ๊ธ๊ผด ๋ค์ด๋ก๋ ์ผ๋ณธ์ด ๋ฒ์ ๋ค์ด๋ก๋ GitHub์์ ๋ณด๊ธฐ system-ui๋ฅผ ๋์ฒดํ๋ ๊ธ๊ผด Apple์ system-ui๊ฐ ์ต์ํ ๋๋ก์๋ San Francisco์ Apple SD ์ฐ๋๊ณ ๋ Neo๊ฐ ์๋ cactus.tistory.com ๊ธ๊ผด ๋ค์ด๋ก๋๋ฅผ ๋๋ฌ์ ๋งฅ์ ์ ์ฅ ํผ๊ทธ๋ง์์ ์ฌ์ฉํ๊ธฐ ์ํด ๊ฐ ํญ๋ชฉ์ ๋๋ธ ํด๋ฆญํด์ ์ค์น Figma ํ
์คํธ๋ฅผ ์ถ๊ฐํ ํ ํฐํธ, ํฐํธ์ ๊ตต๊ธฐ, ์๊ฐ, ํ๊ฐ์ ์ง์ ๊ทธ ํ Text ์์ ์ ๋ค๊ฐ ์์ด์ฝ ํด๋ฆญ ํ
์คํธ ์คํ์ผ ๋ฉ๋ด๊ฐ ๋์ค๋ฉด + ๋ฒํผ์ ๋๋ฌ ์๋ก์ด ํ
์คํธ ์คํ์ผ์ ๋ฑ๋ก ์๋ก์ด ํ
์คํธ ์คํ์ผ์ ์ด๋ฆ์ ์ง์ ํ ๋ค create style์ ๋๋ฌ ์ ์ฅ..
Attributed ํ
์คํธ๋ ๋ณ๋ค๋ฅธ ์ฝ๋ ์์ด ๋ฐ์ค, ํ์ดํผ๋งํฌ ์ด๋์ ์์ฑํ ์ ์์ต๋๋ค. struct LinkView: View { var body: some View { Link("๋ค์ด๋ฒ๋ก ์ด๋", destination: URL(string: "https://naver.com")!) } } Link๋ผ๋ ๋ทฐ๋ฅผ ์ด์ฉํ๋ฉด ํ๋ฉด์ ๋ณด์ผ ํ
์คํธ์ ์ด๋ํ ์น์ฌ์ดํธ ์ฃผ์๋ฅผ ์ฝ๊ฒ ์์ฑํ ์ ์์ต๋๋ค. Link("๋ค์ด๋ฒ๋ก ์ด๋", destination: URL(string: "https://naver.com")!) .fontWeight(.heavy) .foregroundStyle(.green) ํฐํธ์ ๋ณ๊ฒฝ๋ ์ฝ์ต๋๋ค. ๋ง์ฝ ์ฌ์ฉ์์๊ฒ ์ด๊ฒ์ด ๋จ์ ํ
์คํธ๊ฐ ์๋ ํ์ดํผ๋งํฌ ์ด๋์ด๋ผ๋ ๊ฒ์ ์ธ์ง ์์ผ ์ฃผ๊ณ ์ถ์ ๊ฒฝ์ฐ ..
bottom card view, botton sheet ๋ฑ ์ฉ์ด๊ฐ ๋ง์๋ฐ modifier์ ์ด๋ฆ์ sheet์
๋๋ค @State private var isShowingSheet: Bool = false ํ๋ฉด์ sheet์ผ๋ก ๋์ธ view๋ฅผ ๋ณด์ฌ์ค์ง ์ฌ๋ถ๋ฅผ ์ํด State๋ฅผ ํ๋ ์ ์ธํด ์ค๋๋ค. false์ด๋ฉด ํ๋ฉด์ ๋ณด์ด์ง ์๊ฒ ๋๊ณ , true์ด๋ฉด ํ๋จ์ sheet ํํ๋ก view๊ฐ ๋ณด์ด๊ฒ ๋ฉ๋๋ค. Button { isShowingSheet.toggle() print(isShowingSheet) } label: { Text("๋ฐํ
์ํธ ๋์ฐ๊ธฐ") } isShowingSheet ๊ฐ์ ๋ฐ๊พธ๊ธฐ ์ํ Button์ ํ๋ ๋ง๋ญ๋๋ค. ๋ฒํผ์ ๋๋ฅด๋ฉด isShowingSheet ์ ํ ๊ธํด ์ค๋๋ค. .sheet(isPrese..
UIKit์์ AVKit์ AVPlayer๋ฅผ ์ฌ์ฉํด์ ๋์์์ ๋ณด์ฌ ์ค ์ ์์์ต๋๋ค. SwiftUI์์ ๋์์์ ํ๋ฉด์ ๋ณด์ฌ์ฃผ๊ณ ์ปจํธ๋กค ํ๊ธฐ ์ํด์๋ UIViewControllerRepresentable์ ์ฌ์ฉํด์ผ ํฉ๋๋ค. UIKit์ UIViewController๋ฅผ SwiftUI์ View๋ก ์ฌ์ฉํ๊ธฐ ์ํด UIViewControllerRepresentable์ ์ฑํํ๋ struct๋ฅผ ์์ฑํด์ผ ํฉ๋๋ค. View๊ฐ ํ๋ฉด์ ๋ณด์ด๋ฉด ์๋์ผ๋ก ๋์์์ด ์คํ๋๋ ๊ฐ๋จํ ์์ ์
๋๋ค. import SwiftUI import AVKit struct VideoPlayerView: UIViewControllerRepresentable { /// ์ธ๋ถ์์ AVPlayer์ ์ํ๋ฅผ ๋ณ๊ฒฝํ๊ฑฐ๋ ์ก์ธ์คํ ์ ์์ @Bindin..
previews๋? ์ฝ๋๊ฐ ๋ณ๊ฒฝ๋๋ฉด ์บ๋ฒ์ค์ ๋์์ธ๊ณผ ๋ ์ด์์์ด ์ค์๊ฐ์ผ๋ก ๋ณ๊ฒฝ๋๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค. ์ด ๋ฏธ๋ฆฌ๋ณด๊ธฐ ๊ธฐ๋ฅ์ ์ ๊ณต ์บ๋ฒ์ค์์ ์ธํฐ๋ ์
์ ์ง์ํจ. ๋ฒํผ ํด๋ฆญ์ print๋ฌธ์ ์ฌ์ฉํด์ ์ฝ์์ ๋ก๊ทธ๋ฅผ ์ฐ๋ ๊ฒ๋ ๊ฐ๋ฅ ๋ค์ํ ๋๋ฐ์ด์ค ํ์
์ง์ ๋คํฌ ๋ชจ๋ ํ์ธ ๊ฐ๋ฅ ๋ทฐ ์ฌ์ด์ฆ์ ๋ง๋๋ก ์กฐ์ ํด์ ๋ทฐ์ ๋ชจ์์ ํ์ธ ํ ์ ์์ static var previews: some View { HikeCustomButtonView() .previewLayout(.sizeThatFits) .padding() } ์บ๋ฒ์ค์์ ๋ง์ฐ์ค ์ปค์ ๋ชจ์์ ๋๋ฌ์ฃผ๋ฉด ํ๋ ์(๋ฒ ์ ค)์ด ์ ๊ฑฐ๋ ๋ฏธ๋ฆฌ๋ณด๊ธฐ ํ๋ฉด์ด ์บ๋ฒ์ค์ ๋ํ๋ฉ๋๋ค.
@inlinable public func foregroundStyle(_ style: S) -> some View where S : ShapeStyle foregroundStyle์ ์ฌ์ฉํด์ Color, ShapeStyle์ ์ง์ ํ ์ ์์ @frozen public struct LinearGradient : ShapeStyle, View LinearGradient๋ ShapeStyle๋ก์ ๊ทธ๋๋์ธํธ์ ๋ฐฉํฅ๊ณผ ์์์ ์ง์ ํ ์ ์๋ค. ex) .foregroundStyle( LinearGradient(colors: [.pink, .purple, .blue], startPoint: .topLeading, endPoint: .bottomTrailing) ) colors์๋ ์์์ ์ง์ ํด ์ฃผ๋ฉด ๋๋ฉฐ ์ธ๋ฑ์ค 0๋ฒ..
์ฐธ๊ณ ์ฌ์ดํธ ๋ฐ ์ถ์ฒ https://www.youtube.com/watch?v=ZQXzZ1hxQwo ์ ์๋ณธ ์์์ ์ฐธ๊ณ ํ์๋ฉด ๋ ์์ธํ ์ ์ ์์ต๋๋ค! ์ ์์์ด ์์ด ํด๋น ํฌ์คํ
์ ๊ณต๋ถํ๋ค ์๊ฒ๋ ์ ๋ง ์ ์ด ๋์์ต๋๋ค. NavigationLink NavigationLink๋ฅผ ์ฌ์ฉํ๋ฉด ๋ค๋น๊ฒ์ด์
์คํ์ ์์ ์ ์์ NavigationView { VStack { NavigationLink(value: , label: View#>) } .padding() } value ๋ ์ด๋ ์ํค๊ธฐ ์ํด ๋งํฌ๋ฅผ ๊ฑธ ๋ทฐ, label์ ์คํ์ผ๋ก ์์ ๋ทฐ๋ฅผ ํด๋ก์ ๋ก ์ ๋ฌ NavigationView { VStack { NavigationLink { Text("๋ ๋ฒ์งธ ๋ทฐ") } label: { Text("์ฒซ ๋ฒ์งธ ๋ทฐ") ..