Develop
2022.12.09 15:38

[swift] UIView에서 subview 찾기

Views 1730 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

UIView에서 하위의 subviews 찾아서 배열을 리턴


import UIKit


extension UIView

{

    func findSubViews<T: UIView>(classOf: T.Type) -> [T] {

        return recursiveSubviews.compactMap { $0 as? T }

    }

    

    var recursiveSubviews: [UIView] {

        return subviews + subviews.flatMap { $0.recursiveSubviews }

    }

}





?

No Articles

Board Pagination Prev 1 ... 70 71 72 73 74 Next
/ 74