I have a view that is used in a UINavigationController and and is automatically pushed down to fit the window as expected. However I need to present the same view as a Model and it does not have a UINavigationController (or need one) so I just add a UINavigationBar like so:
if (presentedAsModal == YES) {
UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[self.view addSubview:navigationBar];
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonSystemItemDone target:nil action:@selector(dismissModalViewControllerAnimated:)];
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Title"];
item.leftBarButtonItem = leftButton;
item.hidesBackButton = YES;
[navigationBar pushNavigationItem:item animated:NO];
[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:0/255.0f green:180/255.0f blue:220/255.0f alpha:1.f]];
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:0/255.0f green:140/255.0f blue:180/255.0f alpha:1.f]];
}
However, the navigationBar does not automatically push down the VC and it ends up covering up part of my View. is there a way to make the VC resize to fit the new available space once the navigationBar is added (I don't want to do it manually).