Skip to content

Instantly share code, notes, and snippets.

@patricklynch
patricklynch / UIView+find.swift
Created November 7, 2017 11:34
Subview recursive search
extension UIView {
func findSubview(where matches: (UIView) -> Bool) -> UIView? {
for subview in subviews {
if matches(subview) {
return subview
} else if let match = subview.findSubview(where: matches) {
return match