You should be able to achieve this by:
- subclassing UIWindow and overriding
drawRect
to draw your image; details about subclassing UIWindow
here
- and then by using
UIAppearance
to control the background colour for the rest of the views in your app (you should set it to clearColor
); details about this here, though I think you'll need to subclass the views used by your controllers in order to cope with the note in the accepted answer
A basic implementation could look like this:
class WallpaperWindow: UIWindow {
var wallpaper: UIImage? = UIImage(named: "wallpaper") {
didSet {
// refresh if the image changed
setNeedsDisplay()
}
}
init() {
super.init(frame: UIScreen.mainScreen().bounds)
//clear the background color of all table views, so we can see the background
UITableView.appearance().backgroundColor = UIColor.clearColor()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func drawRect(rect: CGRect) {
// draw the wallper if set, otherwise default behaviour
if let wallpaper = wallpaper {
wallpaper.drawInRect(self.bounds);
} else {
super.drawRect(rect)
}
}
}
And in AppDelegate:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? = WallpaperWindow()