Using Swift/IOS/iPad Xcode. How to change button text programmatically post app start. If the button text is X change it to Y.
You should create a Bool State var that holds the condition to choose between X and Y.
@State private var buttonXCond = true // toggle to false when needed
Then in Button, have a conditional Label:
Button {
// The action
}
} label: {
Text("\(buttonXCond ? "X" : "Y")")
}
Is it UIKit or SwiftUI ? For SwiftUI, see previous post.
For UIKit:
myButton.setTitle(buttonXCond ? "X" : "Y", for: UIControl.State.normal)