Guest User

Untitled

a guest
Oct 21st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. extension UIView {
  2. func getSpecifiedSubviews<T: UIView>() -> [T] {
  3. var subviews = [T]()
  4. self.subviews.forEach { subview in
  5. subviews += subview.getSpecifiedSubviews() as [T]
  6. if let subview = subview as? T {
  7. subviews.append(subview)
  8. }
  9. }
  10. return subviews
  11. }
  12. }
  13.  
  14. // Ex: let allTextField: [UITextField] = self.getSpecifiedSubviews()
Add Comment
Please, Sign In to add comment