Advertisement
priore

Find the view's recursively with Generics

Aug 29th, 2017
351
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.37 KB | None
  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.     }
Advertisement
RAW Paste Data Copied
Advertisement