I am attempting to program in swift without storyboards/interface builder. When I press a UIButton, it does not change color like it would had I created it on the storyboard file. How can I enable this visual feature?
Here is (roughly) my code:
import UIKit
class MyView: UIView {
var myButton: UIButton
init(buttonTitle: String) {
myButton = UIButton()
myButton.translateAutoresizingMaskIntoConstraints = false
myButton.setTitle(buttonTitle, forState: .Normal)
myButton.setTitleColor(.blueColor(), forState: .Normal)
super.init(frame: CGRect())
addSubview(myButton)
var layoutConstraints = [NSLayoutConstraints]()
//... autolayout ...
NSLayoutConstraint.activateConstraints(layoutConstraints)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Thanks in advance.