【发布时间】:2019-08-16 05:12:24
【问题描述】:
我的设计看起来像这样:
当我将它包裹在一个 Button 中时,图像和“HOME”文本会向中心移动:
我正在尝试使内容与左侧对齐,但我遇到了问题。这是组成这个组件的代码。
struct HomeSection: View {
var body: some View {
Button(action: {
}) {
Group {
Spacer().frame(width: 0, height: 36.0, alignment: .topLeading)
HStack {
Image("home")
.resizable()
.frame(width: 24, height: 24)
.foregroundColor(.navigationTextGrey)
Text("HOME")
.bold()
.font(.system(size: 17.0))
.foregroundColor(Color.navigationTextGrey)
.padding(.leading, 4.0)
}
Rectangle()
.fill(Color.navigationTextGrey)
.frame(width: UIScreen.main.bounds.width - 60, height: 1)
.padding(.top, 6.0)
}
}
}
}
【问题讨论】: