[Solved] How to not repeat code in Swift for attributes of button? [closed]


Your answer really isn’t ideal for stackoverflow since it’s not a direct problem your looking for help with, but instead a question of best practice. Check the code of conduct again.

However you can do the following:

(If you need those buttons to be instanced/complete right away)

a) Create a private static function in your class which builds your buttons with the attributes, and gives them the text and selector you pass via parameters.

b) Create a private static function which only applies the attributes you require

(If you just want to apply the same style)

a) Create a private function in your class which stylises all buttons upon viewDidLoad

solved How to not repeat code in Swift for attributes of button? [closed]