我有一个设计看起来像这样:
当我把它包裹在按钮里时,图像和“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)
}
}
}
}