IOS开发之UIView总结1

 太长了,请看 http://blog.csdn.net/xdrt81y/article/details/9128695

  1. performSelector:  
  2. performSelector:withObject:  
  3. performSelector:withObject:withObject:  

 实际调用

 

  1. [self performSelector:@selector(displayViews) withObject:nil afterDelay:1.0f];  

  有三个方法分别是

 

  1. //父视图   
  2. [self.view superview]  
  3. //所有子视图  
  4.  [self.view subviews]  
  5. //自身的window  
  6.  self.view.window  

循环一个视图下面所有视图的方法

 

  1. NSArray *allSubviews(UIView *aView)  
  2. {  
  3.     NSArray *results = [aView subviews];  
  4.     for (UIView *eachView in [aView subviews])  
  5.     {  
  6.         NSArray *riz = allSubviews(eachView);  
  7.         if (riz) {  
  8.             results = [results arrayByAddingObjectsFromArray:riz];  
  9.         }  
  10.     }  
  11.     return results;  
  12. }  

循环返回一个APPLICATION里面所有的VIEW

 

  1. // Return all views throughout the application  
  2. NSArray *allApplicationViews()  
  3. {  
  4.     NSArray *results = [[UIApplication sharedApplication] windows];  
  5.     for (UIWindow *window in [[UIApplication sharedApplication] windows])  
  6.     {  
  7.         NSArray *riz = allSubviews(window);  
  8.         if (riz) results = [results arrayByAddingObjectsFromArray: riz];  
  9.     }  
  10.     return results;  
  11. }  

 找出所有的父视图

 

  1. // Return an array of parent views from the window down to the view  
  2. NSArray *pathToView(UIView *aView)  
  3. {  
  4.     NSMutableArray *array = [NSMutableArray arrayWithObject:aView];  
  5.     UIView *view = aView;  
  6.     UIWindow *window = aView.window;  
  7.     while (view != window)  
  8.     {  
  9.         view = [view superview];  
  10.         [array insertObject:view atIndex:0];  
  11.     }  
  12.     return array;  
  13. }  
原文地址:https://www.cnblogs.com/ejllen/p/3755757.html