【发布时间】:2013-02-17 21:20:38
【问题描述】:
我正在使用以下代码为我的导航栏创建自定义右栏按钮项:
// create a toolbar
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 50, 44.01)];
// create the array to hold the button, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:1];
// create a toolbar item with image
NSString* pathToSettingsResourceFile = [[NSBundle mainBundle] pathForResource:@"19-gear" ofType:@"png"];
UIImage* settingsImage = [[[UIImage alloc] initWithContentsOfFile:pathToSettingsResourceFile] autorelease];
settings = [[UIBarButtonItem alloc]initWithImage:settingsImage style:UIBarButtonItemStylePlain target:self action:@selector(showSettings:)];
settings.enabled = FALSE;
// add button to toolbar
[buttons addObject:settings];
[tools setItems:buttons animated:NO];
[buttons release];
// add toolbar as a right bar button item
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:tools] autorelease];
[tools release];
直到 ios 6 按预期工作,从 ios 6 我得到这个奇怪的矩形背景
添加
tools.opaque = NO;
tools.backgroundColor = [UIColor clearColor];
没用,
请帮我摆脱这个背景
提前致谢, 阿米特
【问题讨论】:
标签: ios6 uinavigationbar rightbarbuttonitem