Navigation bar button item image color is different when design through xib of xcode5

前端 未结 6 591
自闭症患者
自闭症患者 2021-02-03 20:46

I am creating navigation bar button using xib but when i going to set image to bar button then image colour is different as original image.

Here is my orignal image.

6条回答
  •  遇见更好的自我
    2021-02-03 21:40

    This is sample working code

    UIImage *myImage = [UIImage imageNamed:@"myImageFile.png"];
    myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:myImage style:UIBarButtonItemStylePlain target:self action:@selector(menuObject:)];
    self.navigationItem.leftBarButtonItem = menuButton;
    

提交回复
热议问题