priore

Find the view's recursively with Generics

Aug 29th, 2017
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     private func getSubviewsOf<T : UIView>(view:UIView) -> [T] {
  2.         var subviews = [T]()
  3.        
  4.         for subview in view.subviews {
  5.             subviews += getSubviewsOf(view: subview) as [T]
  6.            
  7.             if let subview = subview as? T {
  8.                 subviews.append(subview)
  9.             }
  10.         }
  11.        
  12.         return subviews
  13.     }
RAW Paste Data