iOS开发笔记-UI-UIView

来源:互联网 发布:注册音乐人软件 编辑:程序博客网 时间:2024/06/07 02:08

在RootViewContronller.m文件中

- (void)viewDidLoad 

下写了以下东西

    //设置背景颜色为白色    self.view.backgroundColor = [UIColor whiteColor];    //1.初始化view    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];    //2.设置view的背景色    view1.backgroundColor = [UIColor redColor];    //3.添加    [self.view addSubview:view1];    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(200, 300, 100, 100)];    view2.backgroundColor = [UIColor blackColor];    [self.view addSubview:view2];    //1.透明度 (0-1)    view1.alpha = 0.5;    //2.是否隐藏    view1.hidden = NO;    //3.中心点    view1.center = self.view.center;    //4.tag (标签)值    view1.tag = 99;    //根据编号找到这个view    UIView *resultView = [self.view viewWithTag:99];    resultView.backgroundColor = [UIColor orangeColor];    //把一个子视图放到前面    [self.view bringSubviewToFront:resultView];    //把一个子视图放到后面    [self.view sendSubviewToBack:resultView];    //子视图自杀    [view1 removeFromSuperview];

这些是view大部分的用法

原创粉丝点击