Custom background for UINavigationBar problems

后端 未结 5 1490
清酒与你
清酒与你 2020-12-29 17:13

I\'ve managed to add a custom background to my navigation bar by using:

UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"UINavigat         


        
5条回答
  •  佛祖请我去吃肉
    2020-12-29 17:48

    On iOS 5 this will not work but the good news is that there is a simple way of doing this

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"name"] forBarMetrics:UIBarMetricsDefault];
    

    NOTE: This will only work on iOS 5 and above so make sure you check iOS version if you want to be backwards compatible.

提交回复
热议问题