Я пытаюсь понять, как я могу добиться чего-то вроде этого:
Это панель инструментов, и я бы хотел оставить текст названия кнопки без создания всего изображения с иконкой И текстом. Как добавить значок слева от UIBarButtonItem
, сохраняя при этом текст с помощью:
UIBarButtonItem *customBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Button" style:UIBarButtonItemStyleBordered target:nil action:nil];
ИЗМЕНИТЬ
Это то, что я достиг с помощью следующего кода:
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setImage:[UIImage imageNamed:@"Test"] forState:UIControlStateNormal];
[customButton setTitle:@"Button" forState:UIControlStateNormal];
customButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
[customButton sizeToFit];
UIBarButtonItem *customBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:customButton];
Два вопроса: первый - размер UIButton
, а второй - это то, что, как вы можете видеть из gif, кнопка не анимируется должным образом, когда я нажимаю внутри кнопки, и когда я отпускаю кран, Любые идеи?