UI 经常用法总结之--- UIWindow UIView (不断更新中)

 UIWindow (UIView)


1.创建一个uiwindow对象

 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];


2.backgroundColor

背景颜色


3.- (void)makeKeyAndVisible;

eg: [self.window makeKeyAndVisible];

设置这个window为主windows,并使其可见


4.rootViewController

把一个视图控制器指定为windows的根视图控制器

eg:self.window.rootViewController = mainVC;



UIView : UIResponder <NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem, UITraitEnvironment, UICoordinateSpace>

1.创建一个UIView对象

UIView *view = [[UIView alloc]initWithFrame:CGRectMake(150, 150, 55, 55)];


2.backgroundColor

背景颜色


3.- (void)addSubview:(UIView *)view;

eg:[self.window addSubview:view];

加入一个view到self.window上


4.- (void)bringSubviewToFront:(UIView *)view;

eg:[self.window bringSubviewToFront:view];

将一个View放到最前面


5.- (void)sendSubviewToBack:(UIView *)view;

[self.window sendSubviewToBack:view];

将一个view放到后面


6.- (void)removeFromSuperview;

eg:[view removeFromSuperview];

将某个view从父视图移除

注意:调用该方法 会使得自己引用计数-1  假设 view上还有view 一并移除掉


7.alpha

透明度 (0 - 1float)带着全部子视图透明度一起改变

eg:View.alpha = 0.3;


8.hidden

隐藏(YES隐藏 / NO显示)

view.hidden = YES;


9.superview

eg:NSLog(@"view的父视图:%@“,view.superview);


10.subviews

eg:NSLog(@“view的子视图:%@“,view.subviews);


11.tag

eg:view.tag = 10000;

view加一个编号,方便父视图查找某个子视图


12.- (UIView *)viewWithTag:(NSInteger)tag;

原文地址:https://www.cnblogs.com/yangykaifa/p/6971861.html