Tag Archives: layer

Changing background image of UINavigationBar with CALayer

Adding a background image to a navigation bar can be done using categories, however I think it is not too elegant, and difficult to modify in application. (though sometimes it is the only solution)
The following code sets the background image using the layer of navigationbar view:
self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"background.png"].CGImage;

Source: Stackoverflow.com