You can use the tintColor
property to change the colour of a UINavigationBar
, but to set an image as the background you'll have to provide your own UINavigationBar
subclass and override the drawRect:
method, for example:
- (void)drawRect:(CGRect)rect {
// Drawing code
UIImage *img = [UIImage imageNamed: @"background-image.png"];
[img drawInRect:CGRectMake(0,
0,
self.frame.size.width,
self.frame.size.height)];
}
If you use Interface Builder to build your UI then to use the custom navigation bar, just select the UINavigationBar element in Interface Builder, open the Inspector and in the Identity tab specify your UINavigationBar subclass in the class field, like so:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…