Bright Future Bright Future - 2 months ago 7
iOS Question

How to set IBOutlet collection's property in batch?

I created an IBOutlet collection of 4 buttons named

buttonCollection
, I need to set the properties of every button like this:

button.layer.borderWidth = 1
button.layer.borderColor = UIColor.white.cgColor
button.layer.cornerRadius = 10


Since
buttonCollection
is an array of UIButtons, I can set the properties one by one, but that'll result in huge amount of code, especially when the buttons gets more, is there a way to set them all at a time?

Answer
for button in buttonCollection {
   //do something on button
}