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;
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-09-28 22:34:23