Skip to content

Instantly share code, notes, and snippets.

@alexcristea
Last active August 29, 2015 14:06
Show Gist options
  • Save alexcristea/0244b50e503e8bf4f25d to your computer and use it in GitHub Desktop.
Save alexcristea/0244b50e503e8bf4f25d to your computer and use it in GitHub Desktop.
Enumerate through all views that are placed under a passed view and get access to each view using a block.
#import <UIKit/UIKit.h>
@interface UIViewController (BrickExtensions)
- (void)enumerateViewsPlacedUnderView:(UIView *)view usingBlock:(void (^)(UIView * view))block;
@end
#import "UIViewController+BKBrickExtensions.h"
@implementation UIViewController (BrickExtensions)
- (void)enumerateViewsPlacedUnderView:(UIView *)view usingBlock:(void (^)(UIView *))block
{
for (UIView *underView in self.view.subviews) {
if(CGRectContainsRect(view.frame, underView.frame))
block(underView);
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment