Search code examples
iosimageviewbackgrounduisplitviewcontroller

Adding background to entire UISplitViewController


Hey I want to add a background image to my UISplitViewController that spans the entire iPad screen and is visible underneath both my master and detail views.

I've tried this a number of different ways and have yet to be successful. If I place it in the splitView.view it just overlays on top of everything in both sub-view controllers. If I place it in the master view controller I can do things normally there (place a UITableView on top of it, etc), but it then covers everything in the detail view controller. Another route I tried was to place my background image in it's own view controller the put the entire split view controller inside that view controller, but no matter what I set the alpha of my split view controller the background is still black.

If someone could point me towards getting this working it would be awesome, thanks!


Solution

  • Got it working!

    First follow along with Apple's example of setting up a UISplitViewController programmatically here: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.html

    then add in this line before adding the VC to the window:

    splitVC.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]];