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;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值