Back-like стрелка на iOS 7
Мне нужно добавить элемент кнопки левой панели в мое приложение, которое выглядит как кнопка возврата системы, но не является кнопкой обратной связи с системой, так как она появится на контроллере просмотра, который является единственным vc моего стека navController и выполняет мои собственные код. Просто написать "Назад" для меня не очень хорошо, так как мне нужно отобразить "<" стрелка. Есть ли способ программно создать стрелку, подобную этой, без создания изображения с этой стрелкой?
![This is how it's supposed to look like]()
Ответы
Ответ 1
Рассмотрим использование фиктивного UIViewController
в качестве контроллера корневого представления для вашего стека UINavigationController
s:
[[UINavigationController alloc] initWithRootViewController:[UIViewController new]];
[navController pushViewController:viewController animated:NO];
Затем вы можете использовать расширение BackButtonHandler для управления кнопкой кнопки возврата (как описано в этот поток):
-(BOOL) navigationShouldPopOnBackButton {
[self dismissModalViewControllerAnimated:YES];
return NO;
}
Ответ 2
Для этого вы можете использовать любой символ Юникода (в любом месте вашего кода).
Вы можете найти то, что вы хотите здесь:
Xcode > Редактировать > Специальные символы...
Найдите arrow
или back
или просмотрите категории.
Затем скопируйте вставить символ там, где это необходимо (в заголовке объекта XIB или в методах setTitle
или setText
, как и любой другой символ)
что-то вроде:
![enter image description here]()
Ответ 3
Попробуйте следующее:
// After you create and place your backButton:
UILabel* arrowLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 20, 20)];
arrowLabel.text = @"<";
arrowLabel.textColor = [backButton titleColorForState:UIControlStateNormal];
arrowLabel.transform = CGAffineTransformMakeScale(1,2);
[backButton addSubview:arrowLabel];
Если addSubview дает вам проблемы, попробуйте
[backButton insertSubview:arrowLabel atIndex:0];
Ответ 4
Посмотрите на перечисление UIBarButtonSystemItem
под концами в документации UIBarButtonItem:
https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UIBarButtonItem_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40007519-CH3-SW2
Это все стили кнопок, предоставляемые Apple:
typedef enum {
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo, // iOS 3.0 and later
UIBarButtonSystemItemRedo, // iOS 3.0 and later
UIBarButtonSystemItemPageCurl, // iOS 4.0 and later
} UIBarButtonSystemItem;
Возможно, перемотка назад или отмена будет достаточно близкой для вас.