macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

barStyle

INDEX>UIKit>UIToolbar

ツールバーのスタイル
@property(nonatomic) UIBarStyle barStyle

定数はUIBarStyle

解説

ツールバーのスタイル

クラス

UIToolbar

Property

使用可能

iPhone2.0

参照

ADC

例文

- (void)applicationDidFinishLaunching:(UIApplication *)application {
	//ツールバーを作る
    CGRect toolbarRect = CGRectMake(0, 431, 320, 49);
    UIToolbar *aToolbar = [[UIToolbar alloc] initWithFrame:toolbarRect];
    self.toolbar = aToolbar;
    [aToolbar release];
    [window addSubview:toolbar];
	
    //ツールバーアイテムを作る
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:LocStr(@"001",@"left") 
					style:UIBarButtonItemStyleBordered target:self action:@selector(toggleRun:)];
    leftItem.width = 150.0;
    [ leftItem setTarget  : self ];
	[ leftItem setAction  : @selector( leftAction: ) ];
	
	//右ビュー
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:LocStr(@"002","right") 
					style:UIBarButtonItemStyleBordered target:self action:@selector(toggleFiltering:)];
    rightItem.width = 150.0;
	[ rightItem setTarget  : self ];
	[ rightItem setAction  : @selector( rightAction: ) ];
	
    //配列を作る
    NSArray *items = [NSArray arrayWithObjects:leftItem, rightItem, nil];
    [leftItem release];
    [rightItem release];
    
    //ツールバーにセットする
	[toolbar setItems:items animated:YES];
	
	aToolbar.barStyle = UIBarStyleDefault;
	switch (aToolbar.barStyle) {
		case UIBarStyleDefault:
			NSLog(@"UIBarStyleDefault");
			break;
		case UIBarStyleBlack:
			NSLog(@"UIBarStyleBlack");
			break;
		case UIBarStyleBlackTranslucent:
			NSLog(@"UIBarStyleBlackTranslucent");
			break;
		default:
			break;
	}
	


	[window makeKeyAndVisible];
}