2
我用下面的代碼創建我的導航欄自定義權欄按鈕項:自定義權限欄按鈕項目不透明
// 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];
沒有幫助,
請幫我擺脫這種背景下提前
感謝, 阿米特