Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Created January 8, 2016 21:27
Show Gist options
  • Save Teino1978-Corp/4a440a8ddc820a62551a to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/4a440a8ddc820a62551a to your computer and use it in GitHub Desktop.
searchController.searchBar.forEachSubviewOfClass(UITextField.self) { textField in
let textField = textField as! UITextField
textField.textColor = .whiteColor()
}
extension UIView {
func forEachSubviewOfClass(type: UIView.Type, apply: (UIView)->()) {
for view in subviews {
if view.isKindOfClass(type) {
apply(view)
} else {
view.forEachSubviewOfClass(type, apply: apply)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment