I have custom background for my standard view and my grouped uitableview which I have declared in
//RooViewController
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:NO]; //Hides the navigation bar
//Add custom background
self.view.backgroundColor = [UIColor clearColor];
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];
[super viewWillAppear:animated];
}
//GroupedTableviewController
- (void)viewWillAppear:(BOOL)animated
{
//Add custom background
self.tableView.backgroundColor = [UIColor clearColor];
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bgplain.png"]];
[super viewWillAppear:animated];
}
The thing with this is the views just disappear and reappear but there is an animation happening between the views sliding left to right… how can I add these custom backgrounds to this view change animation?
You need to set a background view of the view that’s appearing, not the view of the parent view controller. By setting the view of the parent view controller you’re essentially switching out that view (which won’t be animate) while the view of the appearing view controller (which is clear, apparently) is animated in. Instead, add the background view to the appearing view controller view, or in your case, just set the color:
self.view.backgroundColor = UIColor colorWithPatternImage:[UIImage imageNamed:@"bgplain.png"]];I also noted that you’ve changing the background view of the parentView in your root view controller, which means the parent view is probably a UINavigationView (also per your comment). In general, you shouldn’t be changing the view characteristics of a navigationController mostly because it’s designed to hold other views/controllers, not display its own view (besides the navigation bar, of course).
So I don’t think you should be messing with
self.parentViewController.viewand stick withself.viewin each view controller.