I’m making a representation of the unit circle and I have the point labels arranged in a circle. I know the origin of the labels are at the center, so they overflow the parent.
Whats the best way to remedy this? Is there a way to grab the bounds of the overflow and just resize them to fit inside the group, or a different solution?
struct UnitCircle: View {
var body: some View {
GeometryReader { geometry in
let diameter = min(geometry.size.width, geometry.size.height)
let radius = (diameter / 2)
Group {
ForEach(unitCirclePoints, id: .angle) { point in
VStack {
PointView(point: point).border(.red).scaleEffect(0.3)
}
.position(
x: radius * CGFloat(cos(Double(-point.angle) * .pi / 180)) + radius,
y: radius * CGFloat(sin(Double(-point.angle) * .pi / 180)) + radius
)
}
}.border(.red)
.frame(width: diameter, height: diameter)
.position(x: geometry.size.width / 2, y: geometry.size.height / 2)
}
}
}