0
我添加了一個工具欄,然後以編程方式向其添加3個按鈕。然而,3個按鈕都混亂到一個角落。我想要做的是在3個按鈕之間留出空間,以便UI看起來很體面。以編程方式將按鈕添加到UIToolBar
我該怎麼做?
UIButton *button = [UIButton buttonWithType:100];
[button addTarget:self action:@selector(hideGender:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"img"] forState:UIControlStateNormal];
[button setTitle:@"Images" forState:UIControlStateNormal];
button.imageEdgeInsets= UIEdgeInsetsMake(0.0, 0.0, 0, 50);
button.tag=0;
UIButton *button2 = [UIButton buttonWithType:100];
[button2 addTarget:self action:@selector(hideSchool:) forControlEvents:UIControlEventTouchUpInside];
button2.tag=2;
button2.imageEdgeInsets= UIEdgeInsetsMake(0.0, 0.0, 0, 50);
[button2 setImage:[UIImage imageNamed:@"img22"] forState:UIControlStateNormal];
UIButton *button3 = [UIButton buttonWithType:100];
[button3 addTarget:self action:@selector(hideCar:) forControlEvents:UIControlEventTouchUpInside];
button.tag=3;
button3.imageEdgeInsets= UIEdgeInsetsMake(0.0, 0.0, 0,50);
[button3 setImage:[UIImage imageNamed:@"img3"] forState:UIControlStateNormal];
UIBarButtonItem *barButtonItem0 = [[UIBarButtonItem alloc] initWithCustomView:button] ;
UIBarButtonItem *barButtonItem2 = [[UIBarButtonItem alloc] initWithCustomView:button2] ;
UIBarButtonItem *barButtonItem3 = [[UIBarButtonItem alloc] initWithCustomView:button3] ;
更新:我希望只使用UIButton的
我想使用UIButtons。 – Illep
好的,讓我編輯我的答案... – pkc456