You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
885 B

//
// UIView+ViewController.m
// neutralWatch
//
// Created by WeiChaoZheng on 2017/12/29.
// Copyright © 2017xTT. All rights reserved.
//
#import "UIView+ViewController.h"
@implementation UIView (ViewController)
- (UIViewController*)getViewController{
UIViewController *viewController = nil;
UIResponder *next = self.nextResponder;
while (next)
{
if ([next isKindOfClass:[UIViewController class]])
{
viewController = (UIViewController *)next;
break;
}
next = next.nextResponder;
}
return viewController;
}
-(NSInteger)getInSuperViewIndex{
NSArray *tempArr = [self superview].subviews;
for (int i = 0; i < tempArr.count; i++) {
UIView *tempView = (UIView*)tempArr[i];
if([tempView isEqual:self]){
return i;
}
}
return -1;
}
@end