UI 創建見View視圖

#import "TestDicAppDelegate.h"


@implementation TestDicAppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    // 產生一個window對象,使它和屏幕的大小一樣。

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Override point for customization after application launch.

    self.window.backgroundColor = [UIColor blackColor];

    // window對象 設置爲主window,並且可見。

    [self.window makeKeyAndVisible];

    

    

    // 1.建立一個UIView對象:

    // 2.UIView通過CGRect結構體確定位置 大小。

    UIView *view9 = [[UIView alloc] initWithFrame:(CGRectMake(150, 10, 200, 440))];

    [view9 setBackgroundColor:[UIColor darkGrayColor]];

    [self.window addSubview:view9];

    

    UIView *view8 = [[UIView alloc] initWithFrame:(CGRectMake(130, 20, 190, 405))];

    [view8 setBackgroundColor:[UIColor orangeColor]];

    view8.alpha = 0.9//透明度

    view8.hidden = NO//隱藏

    

    view8.tag = 10000 //設置viewtag值(作用:方便父視圖快速定位子視圖)

    

    [self.window addSubview:view8];

    NSLog(@"%@", view8.superview);

    

    // 通過tag尋找子視圖

//    UIView *viewTemp = [self.window viewWithTag:10000];

    

    

    UIView *view7 = [[UIView alloc] initWithFrame:(CGRectMake(110, 40, 180, 355))];

    [view7 setBackgroundColor:[UIColor purpleColor]];

    [self.window addSubview:view7];

    

    UIView *view6 = [[UIView alloc] initWithFrame:(CGRectMake(90, 60, 170, 305))];

    [view6 setBackgroundColor:[UIColor brownColor]];

    [self.window addSubview:view6];

    

    UIView *view3 = [[UIView alloc] initWithFrame:(CGRectMake(70, 80, 160, 255))];

    [view3 setBackgroundColor:[UIColor blueColor]];

    [self.window addSubview:view3];

    

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 150, 205)];

    [view setBackgroundColor:[UIColor yellowColor]];

    

    // 3.view對象 添加到 window

    [self.window addSubview:view];

    

    

    UIView *view1 = [[UIView alloc] initWithFrame:(CGRectMake(30, 120, 140, 155))];

    [view1 setBackgroundColor:[UIColor greenColor]];

    [self.window addSubview:view1];

    

    UIView *view2 = [[UIView alloc] initWithFrame:(CGRectMake(10, 140, 130, 105))];

    [view2 setBackgroundColor:[UIColor redColor]];

    [self.window addSubview:view2];

    

    UIView *view4 = [[UIView alloc] initWithFrame:(CGRectMake(-10, 160, 120, 55))];

    [view4 setBackgroundColor:[UIColor cyanColor]];

    [self.window addSubview:view4];

    

    UIView *view5 = [[UIView alloc] initWithFrame:(CGRectMake(20, 180, 70, 15))];

    [view5 setBackgroundColor:[UIColor magentaColor]];

    view5.alpha = 0.5;

    [self.window addSubview:view5];

    

    // 改變中心點

//    view3.center = CGPointMake(0, 0);

    

    // 4.內存管理(釋放)

    [view release];

    return YES;

}


- (void)applicationWillResignActive:(UIApplication *)application

{

    // 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.

    // 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.

}


- (void)applicationDidEnterBackground:(UIApplication *)application

{

    // 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. 

    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}


- (void)applicationWillEnterForeground:(UIApplication *)application

{

    // 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.

}


- (void)applicationDidBecomeActive:(UIApplication *)application

{

    // 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.

}


- (void)applicationWillTerminate:(UIApplication *)application

{

    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}


@end


發佈了27 篇原創文章 · 獲贊 3 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章