#import"AppDelegate.h"@implementationAppDelegate-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{//创建一个窗口对象,(UIEWindow),让窗口根屏幕一样大self.window=[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];//属性是retain或者copy修饰,都要dealloc//Overridepointforcustomizationafterapplicationlaunch.//给这个全屏的窗口设置一个颜色self.window.backgroundColor=[UIColorwhiteColor];//把window设置为主窗口而且可见的,注意:一个应用程序只能显示一个window[self.windowmakeKeyAndVisible];//学习新类--1.看继承关系2.看新类没有没有自己的初始化方法/构造器UIView*view=[[UIViewalloc]initWithFrame:CGRectMake(100,150,100,130)];//设置属性view.backgroundColor=[UIColorgrayColor];//让视图显示NO/隐藏YES//隐藏的时候,会吧view所有的子视图全部隐藏view.hidden=NO;//view透明度)0-1)view.alpha=0.5;//将一个view添加到另一view上[_windowaddSubview:view];//将view添加到window上。NSLog(@"%@",view.superview);NSLog(@"111111%@",_window.subviews);//tag值作用:方便父视图迅速找到某一子视图,tag值作为一个视图的标记view.tag=1000;//重新调整view的位置和大小view.frame=CGRectMake(0,0,100,100);//view的中心点,来调整view的位置view.center=CGPointMake(150,200);//内存管理[viewrelease];//重新创建一个view1UIView*view1=[[UIViewalloc]initWithFrame:CGRectMake(150,250,50,100)];view1.backgroundColor=[UIColorblueColor];[_windowaddSubview:view1];[view1release];//重新创建一个view2UIView*view2=[[UIViewalloc]initWithFrame:CGRectMake(200,50,50,100)];view2.backgroundColor=[UIColorredColor];[_windowaddSubview:view2];[view2release];//重新创建一个view2UIView*view3=[[UIViewalloc]initWithFrame:CGRectMake(60,350,200,200)];view3.backgroundColor=[UIColoryellowColor];[_windowaddSubview:view3];[view3release];UIView*view4=[[UIViewalloc]initWithFrame:CGRectMake(60,350,100,100)];view4.backgroundColor=[UIColorgreenColor];[_windowaddSubview:view4];[view4release];//调整视图的层级关系//调整是由父视图来完成,可以对所有的子视图进行调整[_windowbringSubviewToFront:view];//把view[UIColorgrayColor](灰色)的这个调整到最上面。。。。。//内存管理-------添加1[_windowrelease];returnYES;}//这里是因为属性用retain或者copy-------添加2-(void)dealloc{[_windowrelease];[superdealloc];}-(void)applicationWillResignActive:(UIApplication*)application{//Sentwhentheapplicationisabouttomovefromactivetoinactivestate.Thiscanoccurforcertaintypesoftemporaryinterruptions(suchasanincomingphonecallorSMSmessage)orwhentheuserquitstheapplicationanditbeginsthetransitiontothebackgroundstate.//Usethismethodtopauseongoingtasks,disabletimers,andthrottledownOpenGLESframerates.Gamesshouldusethismethodtopausethegame.}-(void)applicationDidEnterBackground:(UIApplication*)application{//Usethismethodtoreleasesharedresources,saveuserdata,invalidatetimers,andstoreenoughapplicationstateinformationtorestoreyourapplicationtoitscurrentstateincaseitisterminatedlater.//Ifyourapplicationsupportsbackgroundexecution,thismethodiscalledinsteadofapplicationWillTerminate:whentheuserquits.}-(void)applicationWillEnterForeground:(UIApplication*)application{//Calledaspartofthetransitionfromthebackgroundtotheinactivestate;hereyoucanundomanyofthechangesmadeonenteringthebackground.}-(void)applicationDidBecomeActive:(UIApplication*)application{//Restartanytasksthatwerepaused(ornotyetstarted)whiletheapplicationwasinactive.Iftheapplicationwaspreviouslyinthebackground,optionallyrefreshtheuserinterface.}-(void)applicationWillTerminate:(UIApplication*)application{//Calledwhentheapplicationisabouttoterminate.Savedataifappropriate.SeealsoapplicationDidEnterBackground:.}@end