【发布时间】:2020-01-09 00:53:07
【问题描述】:
var body: some View {
VStack(alignment: .leading) {
Text("Title")
.bold()
.font(Font.custom("Helvetica Neue", size: 36.0))
...
Button(action: {}){
Text("Create")
.bold()
.font(Font.custom("Helvetica Neue", size: 24.0))
.padding(20)
.foregroundColor(Color.white)
.background(Color.purple)
.cornerRadius(12)
}
}.padding(20)
}
我希望这两个特定元素有不同的对齐方式。标题必须有一个前导对齐,但另一方面按钮位于中心。现在我将 VStack 对齐设置为领先。我对 Swift UI 不太熟悉,所以第一个想法是使用几个具有不同对齐方式的垂直堆栈,但我认为它可以更轻松地完成。如果我向按钮添加对齐指南,它也不起作用。
【问题讨论】:
-
Button() .frame(width: UIScreen.main.bounds.width/2, height: UIScreen.main.bounds.height /2, alignment: .center)