zoukankan      html  css  js  c++  java
  • iOS中的UIView的基本属性1

    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        //UIweindow 应用程序的窗口,用于将内容展示给用户
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        //创建view
        UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(50, 90, 100, 100)];
        //设置背景颜色
        redView.backgroundColor=[UIColor redColor];
        
        //添加到父控件
        [self.window addSubview:redView];
    
        
        //一个视图只有一个父视图
        UIView *grayView = [[UIView alloc] initWithFrame:CGRectMake(50,200, 100,100)];
        
        UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(56,200, 100,100)];
        [self.window addSubview:greenView];
        
        
        greenView.backgroundColor = [UIColor greenColor];
        grayView.backgroundColor = [UIColor grayColor];
      
        
        [redView addSubview:grayView];
        [self.window addSubview:grayView];
    
        //释放内存
        [redView release];
        [grayView release];
        [greenView release];
        
        
        
        
        //UIView的重要属性
        //1.backgroundColor 背景颜色
        //2.hidden 显隐性 //控制视图的显隐性,默认为NO
        //3.alpha 透明度,控制视图的透明度,取值范围0.0 - 1.0
        //4.superview 获得父视图
        //5.subvievs 获得子视图,使用数组进行管理,子视图的添加是有序的,添加顺序对应上数组元素的位置
        //6.tag 标签,唯一标示指定视图
        [self.window viewWithTag:250];
        
        //通过字视图也可以获得 子
        //UIView *lase = [self.window subviews].lastObject;
        
        
            
        
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
    
        //设置Window的背景颜色
        //让UIwindow成为程序的主窗口,并且可视
        //[self.window makeKeyAndVisible];
      
        return YES;
    }
  • 相关阅读:
    ASP.NET(C#) DataSet数据导出到Excel
    GridView生成导出EXECL
    Gridview 手动排序实现
    用DirectoryInfo搜索文件夹时过滤隐藏文件夹
    为 DropDownList 选项添加背景或样式 收
    IIS中 CS0016: 未能写入输出文件 …….*.dll拒绝访问
    singletontheorylazy.cs
    adaptertwowayseabird.cs
    StatefulLabel.cs
    LifecycleControl.cs
  • 原文地址:https://www.cnblogs.com/wohaoxue/p/4764812.html
Copyright © 2011-2022 走看看