【发布时间】:2013-12-16 09:39:32
【问题描述】:
在iOS7中,我创建了一个UIBarButtonItem并初始化了一个颜色为绿色的图像。但是UIBarButtonItem的图像的最终外观是一个形状相同但颜色不同的图像。颜色被更改为蓝色。
代码如下:
_recordVoiceItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"voiceIcon"] style:UIBarButtonItemStylePlain target:self action:nil];
_textView = [[UITextView alloc] initWithFrame:CGRectMake(40, 4, 220, BOTTOM_BAR_HEIGHT - 2*4)];
_textView.layer.borderWidth = 1.f;
_rightItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"modeIcon"] style:UIBarButtonItemStylePlain target:self action:nil];
_bottomBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.frame.origin.y + self.view.frame.size.height - BOTTOM_BAR_HEIGHT, self.view.frame.size.width, BOTTOM_BAR_HEIGHT)];
_bottomBar.items = @[_recordVoiceItem,[[UIBarButtonItem alloc] initWithCustomView:_textView],_rightItem];
[self.view addSubview:_bottomBar];
我已经尝试创建一个UIToolBar 并通过Interface Builder 向其中添加一些项目。外观很好。 UIBarButtonItem 的图片颜色就是原始图片的颜色。
如果我想通过编写代码来设置UIToolBar 或UIBarButtonItem 的某些属性,我怀疑是否需要添加一些代码。你能告诉我怎么做吗?
【问题讨论】:
标签: ios uibarbuttonitem uitoolbar