How to place a UIImage in Navigationbar such that its a logo?

后端 未结 8 795
伪装坚强ぢ
伪装坚强ぢ 2020-12-22 07:30

\"enter\"enterI

8条回答
  •  忘掉有多难
    2020-12-22 08:22

    I think this is the problem with image rendering mode. Can you try the below code

        UIImage *logo = [[UIImage imageNamed:@"logo"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
        UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithImage:logo style:UIBarButtonItemStylePlain target:self action:nil];
        self.navigationItem.leftBarButtonItem = item;
    

    You can even try with your current code by setting the UIImageRenderingModeAlwaysOriginal.

提交回复
热议问题