次のコードを使用して、navbar のカスタム右バー ボタン項目を作成しています。
// 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];
役に立たない、
この背景を取り除くのを手伝ってください
前もってありがとう、アミット