Develop
2022.12.09 15:38

[swift] UIView에서 subview 찾기

Views 1750 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 }

    }

}





?

List of Articles
No. Category Subject Author Date Views
5 System/OS [macos] How to Fix ‘You Shut Down Your Computer Because of a Problem’ file hooni 2022.06.01 788
4 System/OS 네트워크 용어 정리 file hooni 2022.11.20 1315
» Develop [swift] UIView에서 subview 찾기 hooni 2022.12.09 1750
2 Etc 영어. 반드시 외워야 할 문장 패턴 100개 file hooni 2023.06.08 1082
1 Etc 원어민이 매일 쓰는 일상표현 150개 file hooni 2023.09.17 971
Board Pagination Prev 1 ... 70 71 72 73 74 Next
/ 74