Created
November 12, 2013 19:26
-
-
Save camdez/7437118 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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