SwiftUI

SwiftUI button 加边框

Button(action: {
    print("Hello button tapped!")
}) {
    Text("Hello World")
        .fontWeight(.bold)
        .font(.title)
        .foregroundColor(.purple)
        .padding()
        .border(Color.purple, width: 5)
}
Button(action: {
    print("Hello button tapped!")
}) {
    Text("Hello World")
        .fontWeight(.bold)
        .font(.title)
        .foregroundColor(.purple)
        .padding()
        .overlay(
            RoundedRectangle(cornerRadius: 20)
                .stroke(Color.purple, lineWidth: 5)
        )
}
Button(action: {
    print("Hello button tapped!")
}) {
    Text("Hello World")
        .fontWeight(.bold)
        .font(.title)
        .foregroundColor(.purple)
        .padding()
        .overlay(
            Capsule(style: .continuous)
                .stroke(Color.purple, style: StrokeStyle(lineWidth: 5, dash: [10]))
        )
}