Вы можете сделать свой собственный Shape
, используя Path
, а затем использовать эту форму в качестве фона для другого вида:
struct ButtonWithSpecialRing: View {
var body: some View {
Button(action: {
print("signed in")
}) {
Text("Sign up!")
.background(CircleWithSemiLine()
.stroke()
.foregroundColor(.gray))
}
}
}
struct CircleWithSemiLine: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
let radius = rect.size.width / 2
path.addArc(center: CGPoint(x: radius, y: radius / 2), radius: radius, startAngle: .degrees(0), endAngle: .degrees(360), clockwise: false)
path.addLine(to: CGPoint(x: radius , y: radius / 2)) // you may play with radius to fit text
return path
}
}
Вы можете играть со смещением немного или с radius
для лучшего центрирования , Я достиг только этого результата за короткое время, но вы можете go дальше:
