-
-
Save alemar11/991a26cdd82b41428f835408e326fffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func forEachSubviewOfType<V: UIView>(type: V.Type, @noescape apply block: V -> Void) { | |
for view in subviews { | |
if let view = view as? V { | |
block(view) | |
} else { | |
view.forEachSubviewOfType(V.self, apply: block) | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
searchController.searchBar.forEachSubviewOfType(UITextField.self) { textField in | |
textField.textColor = .whiteColor() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment