Reputation: 141
I know there are various versions of this question already on stack overflow but none of those could help me. It just won't work
I'm trying to programatically change a UIButtons title here:
override func viewDidLoad() {
super.viewDidLoad()
semesterTableView.dataSource = self
semesterTableView.delegate = self
topView.addShadow(heightOffset: 1)
bottomView.addShadow(heightOffset: -2.25)
bottomView.layer.shadowOpacity = 0.2
addButton.layer.cornerRadius = 10
addButton.setTitle("Test", for: UIControlState.normal) //<--- Here
}
As you can see I'm also adding a corner radius to the button what works, therefore the button is indeed connected ( as you can see here:Proof of connection ). Just the title change won't work.
Upvotes: 2
Views: 222
Reputation: 321
Is your button title set as "attributed" in the storyboard? If so you will need to set the attributedTitle. See: https://developer.apple.com/documentation/uikit/uibutton/1624012-setattributedtitle
Upvotes: 4