1 UIToolBar 안에 4 개의 UIBarButtonItem (penButton, textButton, highlightButton & stampButton)이 있고 각 단추를 세로로 가져 오려고합니다. 이제는 가로로 정렬됩니다.UIToolbar의 UIBarButtonItem 위치
NSBundle *currentBundle = [NSBundle bundleForClass:[self class]];
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(5, 20, 200, 200)];
[toolBar setBackgroundColor:[UIColor clearColor]];
UIButton *penTool = [UIButton buttonWithType:UIButtonTypeCustom];
penTool.frame = CGRectMake(0, 0, 30, 30);
[penTool setImage:[UIImage imageNamed:@"pen-but" inBundle:currentBundle compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
[penTool addTarget:self action:@selector(drawButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
penTool.autoresizingMask = UIViewAutoresizingNone;
penTool.exclusiveTouch = YES;
penTool.tag = 1;
UIBarButtonItem * penButton = [[[UIBarButtonItem alloc] initWithCustomView:penTool] autorelease];
UIButton *textTool = [UIButton buttonWithType:UIButtonTypeCustom];
textTool.frame = CGRectMake(0, 0, 30, 30);
[textTool setImage:[UIImage imageNamed:@"text-but" inBundle:currentBundle compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
[textTool addTarget:self action:@selector(drawButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
textTool.autoresizingMask = UIViewAutoresizingNone;
textTool.exclusiveTouch = YES;
textTool.tag = 2;
UIBarButtonItem * textButton = [[[UIBarButtonItem alloc] initWithCustomView:textTool] autorelease];
UIButton *highlightTool = [UIButton buttonWithType:UIButtonTypeCustom];
highlightTool.frame = CGRectMake(0, 0, 30, 30);
[highlightTool setImage:[UIImage imageNamed:@"squarefill-but" inBundle:currentBundle compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
[highlightTool addTarget:self action:@selector(drawButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
highlightTool.autoresizingMask = UIViewAutoresizingNone;
highlightTool.exclusiveTouch = YES;
highlightTool.tag = 3;
UIBarButtonItem * highlightButton = [[[UIBarButtonItem alloc] initWithCustomView:highlightTool] autorelease];
UIButton *stampTool = [UIButton buttonWithType:UIButtonTypeCustom];
stampTool.frame = CGRectMake(8, 8, 30, 30);
[stampTool setImage:[UIImage imageNamed:@"approved" inBundle:currentBundle compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
[stampTool addTarget:self action:@selector(drawButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
stampTool.autoresizingMask = UIViewAutoresizingNone;
stampTool.exclusiveTouch = YES;
stampTool.tag = 4;
UIBarButtonItem * stampButton = [[[UIBarButtonItem alloc] initWithCustomView:stampTool] autorelease];
NSArray *buttons = [NSArray arrayWithObjects: penButton, textButton, highlightButton, stampButton, nil];
[toolBar setItems:buttons animated:NO];
[self.view addSubview:toolBar];
어떻게하면 수직으로 정렬 될 수 있습니까?
그래서 세로 도구 모음을 만들려고합니까? – CZ54