self.navigationItem.rightBarButtonItem=[[UIBarButtonItem
alloc] initWithImage:[UIImage
imageNamed:@"MoreImage"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(moreItemPress)];
用这样的方法。设置的背景图片,颜色变掉了。不是原来设置的图片颜色。
能够用第二种方式,能够解决变色的问题。
UIButton*rightButton = [[UIButton
,,,)];
[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;