In Swift 3, 4, 5:
button.setTitle("Button Title", for: .normal)
Otherwise:
button.setTitle("Button Title", forState: UIControlState.Normal)
Also an @IBOutlet
has to declared for the button
.
More Related Contents:
- Make a UIButton programmatically in Swift
- How to change UIButton image in Swift
- Reset Score Button iOS
- SourceKitService Terminated
- Add an element to an array in Swift
- Xcode, where to assign the segue identifier
- Swift 4 “This class is not key value coding compliant”
- Passing data back from view controllers Xcode
- how to use writeToFile to save image in document directory?
- ViewDidAppear is not called when opening app from background
- How to use generic protocol as a variable type
- Xcode NSManagedObject subclass contains optionals when they are marked as non-optional
- How to create a delay in Swift?
- Round Top Corners of a UIButton in Swift
- Xcode 9 Swift Language Version (SWIFT_VERSION)
- Dynamic Height Issue for UITableView Cells (Swift)
- Passing Image to another View Controller (Swift)
- @IBDesignable crashing agent
- Passing parameters to a method called by NSTimer in Swift
- Xcode 9 – failed to emit precompiled header [duplicate]
- How can I change height of Navigation Bar – Swift 3
- How to check if a file exists in the Documents directory in Swift?
- Swift – Saving highscore using NSUserDefaults
- After upgrading to Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView
- xcode 7.1 swift framework app builds but not archiving
- Create and perform segue without storyboards
- Facebook Graph API GET request – Should contain “fields” parameter (Swift, Facebook SDK v4.5.1)
- GM release of Xcode 6 compile
- Rotation only in one ViewController
- Determinate finish loading website in webView with Swift in Xcode