What is the best practice to let multiple buttons share the same appearance?
Right now I'm creating those buttons in a loop like this:
for i in 0..<10{
let button = UIButton()
button.setTitle(String(i), for: .normal)
button.backgroundColor = #colorLiteral(red: 0.3137254902, green: 0.2745098039, blue: 0.2745098039, alpha: 0.5977632705)
numberButtons.append(button)
button.layer.borderColor = #colorLiteral(red: 0.04296875, green: 0.04296875, blue: 0.04296875, alpha: 0.5).cgColor
button.layer.borderWidth = 1.0
button.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
}
What is Swift way to do such things? Subclass UIButton? Or add some initialising method as extension?