Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (UIView *)viewOfClass:(NSString *)classStr insideView:(UIView *)view withCondition:(ViewTestBlock)viewTestBlock {
- return [self viewOfClass:classStr insideView:view shouldMatchClassStrictly:NO withCondition:viewTestBlock];
- }
- + (UIView *)viewOfClass:(NSString *)classStr insideView:(UIView *)view shouldMatchClassStrictly:(BOOL)shouldMatchClassStrictly withCondition:(ViewTestBlock)viewTestBlock {
- Class class = NSClassFromString(classStr);
- for (UIView *v in view.subviews) {
- UIView *result;
- if (shouldMatchClassStrictly ? [v isMemberOfClass:class] : [v isKindOfClass:class]) {
- if (!viewTestBlock || viewTestBlock(v)) {
- result = v;
- }
- }
- else {
- result = [self viewOfClass:classStr insideView:v shouldMatchClassStrictly:shouldMatchClassStrictly withCondition:viewTestBlock];
- }
- if (result) {
- return result;
- }
- }
- return nil;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement