Appdelegate:
1 #import "AppDelegate.h"2 #import "TestController.h"3 4 @interfaceappdelegate ()5@property (nonatomic,strong) TestController *Controller;6 @end7 8 @implementationappdelegate9 Ten One-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions { A //Override point for customization after application launch. -Self.window =[[UIWindow alloc]init]; - theSelf.controller =[[TestController alloc]init]; - -Self.window.rootViewController =Self.controller; - + [Self.window makekeyandvisible]; - returnYES; +}
TestController:
1 #import "TestController.h"2 #import "RootView.h"3 4 @interfaceTestController ()5 6@property (nonatomic,strong) Rootview *Rootview;7 8 @end9 Ten @implementationTestController One A- (void) Viewdidload - { - [Super Viewdidload]; the -Self.rootview =[[Rootview Alloc]initwithframe:[[uiscreen Mainscreen]bounds]]; -Self.view =Self.rootview; - } + - @end
Rootview Inheritance UIView
1 #import "RootView.h"2 3 @interfaceRootview ()4 5 @end6 7 @implementationRootview8 9-(Instancetype) initWithFrame: (CGRect) FrameTen { OneSelf =[Super Initwithframe:frame]; A if(self) { -Self.backgroundcolor =[Uicolor Bluecolor]; - } the returnSelf ; - } - - @end
ios--write view in pure code mode