Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension UIView {
- func getSpecifiedSubviews<T: UIView>() -> [T] {
- var subviews = [T]()
- self.subviews.forEach { subview in
- subviews += subview.getSpecifiedSubviews() as [T]
- if let subview = subview as? T {
- subviews.append(subview)
- }
- }
- return subviews
- }
- }
- // Ex: let allTextField: [UITextField] = self.getSpecifiedSubviews()
Add Comment
Please, Sign In to add comment