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

来源:互联网 发布:软件风格 编辑:程序博客网 时间:2024/06/05 11:45

 UIWindow (UIView)


1.创建一个uiwindow对象

 self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];


2.backgroundColor

背景颜色


3.- (void)makeKeyAndVisible;

eg: [self.windowmakeKeyAndVisible];

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


4.rootViewController

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

eg:self.window.rootViewController = mainVC;



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

1.创建一个UIView对象

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


2.backgroundColor

背景颜色


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

eg:[self.windowaddSubview:view];

添加一个view到self.window上


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

eg:[self.windowbringSubviewToFront:view];

将一个View放到最前面


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

[self.windowsendSubviewToBack: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;

0 0
原创粉丝点击