UIToolBarに透明な背景(iBooksに似ています)を作成したいのですが、translucent
プロパティを設定することで幸運を祈ることはありません。UIToolbarの背景を透明にするには?
ここに私のコードです:
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
NSMutableArray *toolBarItems = [[NSMutableArray alloc] init];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil]];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Source" style:UIBarButtonItemStyleBordered target:nil action:nil]];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Aa" style:UIBarButtonItemStyleBordered target:nil action:nil]];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Rabbit" style:UIBarButtonItemStyleBordered target:nil action:nil]];
toolBar.items = toolBarItems;
toolBar.translucent = YES;
[self.view addSubview:toolBar];
それはまだこのように出てくる:
これを行うには、透明な背景画像を設定する必要があると思います。ちょうど1x1ピクセルの透明なpngを作成してください。 – MTurner
@doug Smithhのようにuitoolbarはuiviewのサブクラスです。レイヤプロパティを使用して、アルファの値を変更して透明にすることができます –
をご覧ください: http://stackoverflow.com/questions/2468831/couldnt-uitoolbar-透明にする#答え-3253738 – Shad