I want to loop through my view subviews, and for each subview loop through its subviews and etc.
so let say I have the following code:
let view = myVC.view
view.backgroundColor = UIColor.clearColor()
then repeat this same for each subview. I want to do it functionally.
any insight is much appreciated.
EDIT:
to make it clear
I'm looking for something like this:
view.subviews.chanageColor() { (aView, aColor) in
aView.backgroundColor = aColor
}
but it should be recursive it goes to each view subview.
Something like this?
func makeAllSubviewsClear(view: UIView!)
{
view.backgroundColor = UIColor.clearColor()
for eachSubview in view.subviews
{
makeAllSubviewsClear(eachSubview)
}
}
called via:
let view = myVC.view
makeAllSubviewsClear(view)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With