• 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;
    }
  • 相关阅读:
    jsp int转String or String转int 方法
    log4j详细使用教程
    SQL 查询当天,本月,本周的记录
    1012Linux流编程的一些知识点
    myeclipse过期以后提示过期以后怎么办?!
    mysql常用命令
    Myeclipse文件没出错,但是项目上显示有错的解决办法
    java的一些命名规范吧
    mysql 按照时间查询
    struts1.x和struts2.x之间的一些区别
  • 原文地址:https://www.cnblogs.com/wohaoxue/p/4764812.html
Copyright © 2020-2023  润新知