self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"MoreImage"] style:UIBarButtonItemStylePlain target:self action:@selector(moreItemPress)];

     用这样的方法。设置的背景图片,颜色变掉了。不是原来设置的图片颜色。

     能够用第二种方式,能够解决变色的问题。

UIButton*rightButton = [[UIButton alloc]initWithFrame:CGRectMake(0,0,30,30)];

[rightButton setImage:[UIImage imageNamed:@"MoreImage"] forState:UIControlStateNormal];

[rightButton addTarget:self action:@selector(moreItemPress) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem*rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];

self.navigationItem.rightBarButtonItem= rightItem;




相关文章:

  • 2021-11-26
  • 2021-09-08
  • 2022-01-06
  • 2021-09-23
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2021-12-19
  • 2022-02-09
  • 2022-12-23
  • 2021-12-23
  • 2021-06-28
相关资源
相似解决方案