Objective-C: Background image and title in Navigation Bar

前端 未结 2 1204
小鲜肉
小鲜肉 2021-01-24 22:22

In need a background image AND a title in my Navigation Bar. For the image I write a category:

@implementation UINavigationBar(MyNavigationBar)
- (void)setBackgr         


        
2条回答
  •  一生所求
    2021-01-24 22:44

    After IOS5 You should do this, for example in AppDelegate


     UIImage *img = [[UIImage imageNamed:@"image.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];
    [[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:0 green: 0 blue:0  alpha:1]];
    

提交回复
热议问题