Youjin Lee.

[SwiftUI Masterclass 2023] Section 8, 9 정리

[SwiftUI Masterclass 2023] Section 8, 9 정리

SwiftUI 공부하기

LinearGradient

LinearGradient(colors: [Color.customGrayMedium, Color.customGrayLight], startPoint: .top, endPoint: .bottom)

SwiftUI는 그라데이션도 적용할 수 있다! 짱이다 colors 배열 안에 적용할 그라데이션들의 색을 순서대로 써주면, startPoint 방향에서 endPoint 방향으로 그라데이션이 적용된다. UIKit 쓸 때 안드로이드에는 그라데이션 구현이 있는데 iOS는 없는 것 같아서 슬펐는데 ... 기쁘다

TabView

TabView { ForEach(fruits[0...5]) { item in FruitCardView(fruit: item) } //: LOOP } //: TAB .tabViewStyle(PageTabViewStyle()) .padding(.vertical, 20) }

SwiftUI의 TabView는 UIKit의 PageViewController와 유사하다. 하나의 화면에 여러 개의 View를 보여주는 방식이고, .tabViewStyle() 로 TabView의 스타일도 지정해줄 수 있다. UIKit보다 훨씬 간편하다.

GroupBox

GroupBox() { HStack { Text("Content source") Spacer() Link("Wikipedia", destination: URL(string: "https://wikipedia.com")!) Image(systemName: "arrow.up.right.square") } .font(.footnote) } }

사실 Group과 GroupBox의 차이는 사실 잘 모르겠다. 좀 더 공부해보고 수정하겠다!

© 2025 Youjin Lee. All rights reserved.