Caps-iOS/CapCollector/Extensions/UIViewExtensions.swift
2020-05-16 11:21:55 +02:00

24 lines
577 B
Swift

//
// UIViewExtensions.swift
// CapFinder
//
// Created by User on 23.03.18.
// Copyright © 2018 User. All rights reserved.
//
import Foundation
import UIKit
extension UIView {
var recursiveSubviews: [UIView] {
var subviews = self.subviews.compactMap{ $0 }
subviews.forEach { subviews.append(contentsOf: $0.recursiveSubviews) }
return subviews
}
func fromNib<T : UIView>() -> T { // 2
return Bundle(for: type(of: self)).loadNibNamed(String(describing: type(of: self)), owner: self, options: nil)!.first! as! T
}
}