Working in swiftui. I have a toggle button and a text with it
struct ContentView: View {
@State private var showToggle = true
var body: some View {
Toggle("Toggle", isOn: $showMyIssues)
}
}
It seems the default is for the text to be on the leading edge of its width and the button to be at the trailing edge of the width *See photo
I have tried setting the alignment to both leading and trailing, but neither the button nor the text seem to adjust..
I need the text to be right next to the toggle button and to be able to set the alignment for the toggle and the text together while the text remains next to the toggle button.
*UPDATE I tried following the answer in this SwiftUI - how to change text alignment of label in Toggle? question. This brings the text to the the trailing edge near the toggle button, which fixes half my problem. But now there is not an easy way to move both the text and the toggle button to the leading (left) edge of the screen. They are stuck to the right
var body: some View {
Toggle(isOn: $showMyIssues) {
Text("My Issues")
.frame(maxWidth: .infinity, alignment: .trailing)
}