I wanted to write this short post as a reminder to myself. Every time I set a UIButton color or title I fail at first because I try to do the following:
//This is incorrect, don't do this let button = UIButton() metricButton.titleLabel.text = "My Amazing Button" button.tintColor = .blue
I always forget about the setters that include the control state. This is how you should actually do it:
//Setting UIButton color and title the right way let button = UIButton() button.setTitle("My Amazing Button", for: .normal) button.setTitleColor(.blue, for: .normal)
Perhaps now I'll finally remember the right way to do it, and I hope you will too!