开发者

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 cov开发者_如何学运维ers 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!


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"]];


I just came across this problem and the solution I've used is to put the background image in the split view controllers view and then send it to the back. Then it appears behind all the other content and as long as the master and detail views have a clear background color you can then see the background image.

So if self is a subclass of UISplitViewController and imgView is a UIImageView that contains the background image then I just added this at the end of the viewDidLoad() (making sure it was after I had assigned view controllers to the split view controller)

    self.view.addSubview(imgView)
    self.view.sendSubviewToBack(imgView)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜