How to control spacing around individual views using padding
SwiftUI/View layout 2019. 11. 14. 15:14반응형
Hacking with Swift 사이트의 강좌 번역본입니다.
How to control spacing around individual views using padding
[동영상 강좌 : https://youtu.be/a3-mc7VxsOw]
SwiftUI는 padding() modifier를 사용해서 뷰 주변에 개별 패딩(padding)을 설정합니다. 다음과 같이 매개변수 없이 사용하는 경우에 모든 면에 시스템 기본 패딩을 갖게 될 것입니다.
VStack {
Text("SwiftUI")
.padding()
Text("rocks")
}
그러나 적용할 패딩과 위치를 사용자정의할 수 있습니다. 따라서 한쪽 면에만 시스템 패딩을 적용하고자 할지도 모릅니다.
Text("SwiftUI")
.padding(.bottom)
또는 모든 면에 얼마만큼의 패딩을 적용할지를 제어하고자 할지도 모릅니다.
Text("SwiftUI")
.padding(100)
또는 뷰의 한쪽 면에 특정 양만큼의 패딩을 추가하기 위해 2가지를 조합할 수도 있습니다.
Text("SwiftUI")
.padding(.bottom, 100)
반응형
'SwiftUI > View layout' 카테고리의 다른 글
How to create views in a loop using ForEach (0) | 2019.11.15 |
---|---|
How to return different view types (0) | 2019.11.14 |
How to change the order of view layering using Z index (0) | 2019.11.14 |
How to layer views on top of each other using ZStack (0) | 2019.11.14 |
How to make a fixed size Spacer (0) | 2019.11.14 |
How to force views to one side inside a stack using Spacer (0) | 2019.11.14 |
How to customize stack layouts with alignment and spacing (0) | 2019.11.14 |
How to create stacks using VStack and HStack (0) | 2019.11.14 |