Skip to content

Instantly share code, notes, and snippets.

@camdez
Created November 12, 2013 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camdez/7437118 to your computer and use it in GitHub Desktop.
Save camdez/7437118 to your computer and use it in GitHub Desktop.
//
// UIView+Hierarchy.m
// OrgSync
//
// Created by Cameron Desautels on 11/12/13.
// Copyright (c) 2013 OrgSync. All rights reserved.
//
#import "UIView+Hierarchy.m"
@implementation UIView (Hierarchy)
- (UIView *)closestAncestorWithClass:(Class)targetClass {
UIView *currentView = self;
while ((currentView = [currentView superview])) {
if ([currentView isKindOfClass:targetClass]) {
return currentView;
}
}
return nil;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment