priore

Find the view's recursively with Generics

Aug 29th, 2017
157
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×