我已经制作了一个在整个应用程序中使用的按钮样式,但我找不到用文本完成此操作的方法,因此我最终不得不每次都手动添加 .font 内容。我想知道是否有一种方法可以设置它,以便我可以采用一致的方式来设置文本样式。这是我用来设置按钮样式的代码。
struct mainPageButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.frame(width: 200, height: 60, alignment: .center)
.overlay(RoundedRectangle(cornerRadius: 25)
.stroke(Color(colorManager.secondaryGreen), lineWidth: 8)
)
.padding(.all, 20)
}
}
Run Code Online (Sandbox Code Playgroud) swiftui ×1