zoukankan      html  css  js  c++  java
  • UI 创建见View视图

      1 #import "TestDicAppDelegate.h"
      2 
      3 @implementation TestDicAppDelegate
      4 
      5 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      6 {
      7     // 产生一个window对象,使它和屏幕的大小一样。
      8     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
      9     // Override point for customization after application launch.
     10     self.window.backgroundColor = [UIColor blackColor];
     11     // 把window对象 设置为主window,并且可见。
     12     [self.window makeKeyAndVisible];
     13     
     14     
     15     // 1.建立一个UIView对象:
     16     // 2.UIView通过CGRect结构体确定位置 大小。
     17     UIView *view9 = [[UIView alloc] initWithFrame:(CGRectMake(150, 10, 200, 440))];
     18     [view9 setBackgroundColor:[UIColor darkGrayColor]];
     19     [self.window addSubview:view9];
     20     
     21     UIView *view8 = [[UIView alloc] initWithFrame:(CGRectMake(130, 20, 190, 405))];
     22     [view8 setBackgroundColor:[UIColor orangeColor]];
     23     view8.alpha = 0.9;  //透明度
     24     view8.hidden = NO;  //隐藏
     25     
     26     view8.tag = 10000;  //设置view的tag值(作用:方便父视图快速定位子视图)
     27     
     28     [self.window addSubview:view8];
     29     NSLog(@"%@", view8.superview);
     30     
     31     // 通过tag寻找子视图
     32 //    UIView *viewTemp = [self.window viewWithTag:10000];
     33     
     34     
     35     UIView *view7 = [[UIView alloc] initWithFrame:(CGRectMake(110, 40, 180, 355))];
     36     [view7 setBackgroundColor:[UIColor purpleColor]];
     37     [self.window addSubview:view7];
     38     
     39     UIView *view6 = [[UIView alloc] initWithFrame:(CGRectMake(90, 60, 170, 305))];
     40     [view6 setBackgroundColor:[UIColor brownColor]];
     41     [self.window addSubview:view6];
     42     
     43     UIView *view3 = [[UIView alloc] initWithFrame:(CGRectMake(70, 80, 160, 255))];
     44     [view3 setBackgroundColor:[UIColor blueColor]];
     45     [self.window addSubview:view3];
     46     
     47     UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 150, 205)];
     48     [view setBackgroundColor:[UIColor yellowColor]];
     49     
     50     // 3.将view对象 添加到 window 上
     51     [self.window addSubview:view];
     52     
     53     
     54     UIView *view1 = [[UIView alloc] initWithFrame:(CGRectMake(30, 120, 140, 155))];
     55     [view1 setBackgroundColor:[UIColor greenColor]];
     56     [self.window addSubview:view1];
     57     
     58     UIView *view2 = [[UIView alloc] initWithFrame:(CGRectMake(10, 140, 130, 105))];
     59     [view2 setBackgroundColor:[UIColor redColor]];
     60     [self.window addSubview:view2];
     61     
     62     UIView *view4 = [[UIView alloc] initWithFrame:(CGRectMake(-10, 160, 120, 55))];
     63     [view4 setBackgroundColor:[UIColor cyanColor]];
     64     [self.window addSubview:view4];
     65     
     66     UIView *view5 = [[UIView alloc] initWithFrame:(CGRectMake(20, 180, 70, 15))];
     67     [view5 setBackgroundColor:[UIColor magentaColor]];
     68     view5.alpha = 0.5;
     69     [self.window addSubview:view5];
     70     
     71     // 改变中心点
     72 //    view3.center = CGPointMake(0, 0);
     73     
     74     // 4.内存管理(释放)
     75     [view release];
     76     return YES;
     77 }
     78 
     79 - (void)applicationWillResignActive:(UIApplication *)application
     80 {
     81     // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     82     // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     83 }
     84 
     85 - (void)applicationDidEnterBackground:(UIApplication *)application
     86 {
     87     // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     88     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     89 }
     90 
     91 - (void)applicationWillEnterForeground:(UIApplication *)application
     92 {
     93     // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
     94 }
     95 
     96 - (void)applicationDidBecomeActive:(UIApplication *)application
     97 {
     98     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     99 }
    100 
    101 - (void)applicationWillTerminate:(UIApplication *)application
    102 {
    103     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    104 }
    105 
    106 @end
    有人说:爱上一座城,是因为城里住着某个人,能够与所爱的人在一起,连光阴都是美的。即便粗茶淡饭,修篱种田,只要有你陪伴就好。那么,找一个青山绿水的地方,寻一处幽静的茅舍,或是云水禅心的庭院,那里有晴朗的阳光和静谧的悠然,还有你明媚的笑脸。掬一捧花香在平淡的日子,握着一路相随的暖意,让爱的馨香在柴米油盐中升腾;在一杯茶的温情里,体味生活的诗意;在一碗粥的清淡中,感受生活的浪漫,每天清晨你和阳光都在,便是我的幸福。——春暖花开 《择一城终老,遇一人白首》
  • 相关阅读:
    vue移动端适配问题
    excel 表格数据转json格式
    常用快捷键
    微信公众号监听返回事件
    总结css常用方法
    封装axios
    初学angular项目中遇到的一些问题
    jquery项目中一些常用方法
    怎样做ie兼容性
    vue事件修饰符
  • 原文地址:https://www.cnblogs.com/-Eric-Liu/p/5563923.html
Copyright © 2011-2022 走看看