Below is my code from app delegate in didFinishLaunchingWithOptions
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
CGRect windowFrame = self.window.frame;
UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, windowFrame.size.height-100, windowFrame.size.height, windowFrame.size.height)];
bottomView.backgroundColor = [UIColor redColor];
[self.window addSubview:bottomView];
// self.viewController.view.frame = CGRectMake(0, 0, windowFrame.size.width, windowFrame.size.height-100);
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
My ViewController is FreeForm and its height is just around 245. As you can see i am trying to put a bottom view that is 100 points height.
I am just trying to learn this.
But the view always filling the entire screen. If i comment out setting view controller as windows rootviewcontroller i can see my bottomview there on the screen.
What i am doing wrong? Please advice.
Thanks.
Instead of
self.window.rootViewController = self.viewController;
when i code
[self.window addSubview:self.viewController.view];
gave me the expected result and it governs the freeform size.
It appears when set as rootviewcontroller it fills the entire available screen regardless of the freeform size set on the XIB.
write only one sentance
[self.window bringSubviewToFront: bottomView];
OR
Add bottomView to window as ,
[[[[UIApplication sharedApplication] delegate] window] addSubview:bottomView];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With