How would I loop through all UIButtons in my view in Swift? I would want to set all the titles to \"\", but my for-loop in Swift is giving an error.
UIButtons
\"\"
This code should work:
for view in self.view.subviews as [UIView] { if let btn = view as? UIButton { btn.setTitleForAllStates("") } }
You need to iterate through the subViews array.