I am trying to set the background image for UINavigationBar.
I tried 2 types of methods,
1. [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"KnavigationBarImage.png"] forBarMetrics:UIBarMetricsDefault];
It is supported in ios 5, but crashes when run it in ios 4.3.
2. self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"KnavigationBarImage.png"].CGImage;
It is working fine in ios 4 , But the image is not displaying in ios 5 Simulator.
I need the code which should work in both version 4 and 5.
Please suggest me.
Thanks.
Write a method like this to find which OS the device has.
While setting the image, check as following and then set the image.