Я хочу добавить UIToolbar
к клавиатуре для моего UITextField
. Вот код, который я использую:
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.tintColor = [UIColor blackColor];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(someFunction)];
doneButton.tintColor = [UIColor blackColor];
UISegmentedControl *directionControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Back", @"Next", nil]];
directionControl.tintColor = [UIColor blackColor];
directionControl.segmentedControlStyle = UISegmentedControlStyleBar;
[directionControl addTarget:self action:@selector(directionControlPressed) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *segItem = [[UIBarButtonItem alloc] initWithCustomView:directionControl];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[toolbar setItems:[NSArray arrayWithObjects:segItem, flexibleSpace, doneButton, nil]];
// Assign the toolbar to the text fields
self.textField.inputAccessoryView = toolbar;
Однако, вот как это выглядит, когда я запускаю код:
![enter image description here](https://i.stack.imgur.com/rYoOk.png)
toolbar
не кажется достаточно высоким; Также я заметил, что оттенок цвета панели инструментов не был подтвержден.
Пожалуйста, кто-нибудь может мне помочь?