using image or tint color on uinavigationbar in iphone?

前端 未结 7 1799
自闭症患者
自闭症患者 2020-12-24 09:58

how do i show a background image on a navigation bar or give tint color to the navigation bar in a native iphone application??

7条回答
  •  醉酒成梦
    2020-12-24 10:30

    This's how I did on iOS4:

    #import  // For .layer 
    
    self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"navigationBarBackgroundImage"].CGImage;
    self.navigationController.navigationBar.tintColor = [UIColor orangeColor];
    

    No need to switch subviews between z-orders (-exchangeSubviewAtIndex:withSubviewAtIndex:), both background image and tintColor set in one line of code, and works with @2x image too.

提交回复
热议问题