Skip to content

Instantly share code, notes, and snippets.

@muukii
muukii / UIView+Util.swift
Last active March 13, 2023 05:54
Find UIView by AccessibilityIdentifier
extension UIView {
public class func findByAccessibilityIdentifier(identifier: String) -> UIView? {
guard let window = UIApplication.sharedApplication().keyWindow else {
return nil
}
func findByID(view: UIView, _ id: String) -> UIView? {
if view.accessibilityIdentifier == id { return view }
for v in view.subviews {