How do I add UIImage to center of UINavigationBar?

后端 未结 2 856
感动是毒
感动是毒 2021-02-20 13:39

My problem is that I have an image with width = 44 and height = 44. This method didn\'t work properly.

[self.navigationController.navig         


        
相关标签:
2条回答
  • 2021-02-20 14:02

    Try this:

    UIImageView *titleView = [[UIImageView alloc] initWithImage:myUIImage];
    [self.navigationItem setTitleView:titleView];
    
    0 讨论(0)
  • 2021-02-20 14:12

    Using Swift :

    var titleView = UIImageView(image: UIImage(named: "nameOfTheImage.ext"))
    self.navigationItem.titleView = titleView
    
    0 讨论(0)
提交回复
热议问题