Color the new tab button image appropriately

This commit is contained in:
Pete Schaffner
2024-02-08 17:46:16 +01:00
parent 8831c601a4
commit 95c8541efd
2 changed files with 62 additions and 19 deletions

View File

@@ -1,6 +1,19 @@
import AppKit
extension NSView {
/// Recursively finds and returns the first descendant view that has the given class name.
func firstDescendant(withClassName name: String) -> NSView? {
for subview in subviews {
if String(describing: type(of: subview)) == name {
return subview
} else if let found = subview.firstDescendant(withClassName: name) {
return found
}
}
return nil
}
/// Recursively finds and returns descendant views that have the given class name.
func descendants(withClassName name: String) -> [NSView] {
var result = [NSView]()