iOS導(dǎo)航欄自定義返回一行代碼搞定 Custom back button of navigation bar just type a line code in iOS
啟用默認(rèn)的自定義返回按鈕 Enable the normal appearance of custom back button
- (void)viewDidLoad {
[super viewDidLoad];
// 要啟用自定義返回按鈕东抹,在基于 EFBaseViewController的控制器
// 的 -viewDidLoad添加這行代碼即可
self.useCustomBack = YES;
}
更改自定義返回按鈕的外觀和行為 Change the appearance and the event handler of custom back button
- (void)viewDidLoad {
[super viewDidLoad];
// 你可以在啟用前更改自定義返回按鈕的外觀和行為
self.customBack_barButtonItem = [[UIBarButtonItem alloc] initWithImage:IMAGE(@"extreme.bundle/icon-close-modal") style:UIBarButtonItemStylePlain target:self action:@selector(buttonAction:)];
self.useCustomBack = YES;
// 也可以在啟用后更改自定義返回按鈕的外觀和行為
self.customBack_barButtonItem = nil;
self.customBack_barButtonItem = [[UIBarButtonItem alloc] initWithImage:IMAGE(@"extreme.bundle/icon-close-modal") style:UIBarButtonItemStylePlain target:self action:@selector(buttonAction:)];
// 另一種方式更改自定義返回按鈕的行為藤滥,同時(shí)作用于返回手勢(shì)
// @WeakObject(self);
// self.customBackHandler = ^(id sender) {
// @StrongObject(self);
// [self performSelector:@selector(buttonAction:) withObject:sender];
// };
}
- (void)buttonAction:(id)sender {
self.useCustomBack = NO;
}
相關(guān)
- 詳見極致框架官網(wǎng)<extreme.framework/EFBaseViewController.h>中自定義返回按鈕部分的介紹。通過(guò)極致框架官網(wǎng)頂部的搜索功能搜索 useCustomBack伪阶。
許可
- 本文采用 BY-NC-SA 許可協(xié)議。即:署名——轉(zhuǎn)載請(qǐng)注明出處;非商業(yè)使用藻雌;相同方式傳播——再分發(fā)的文章許可與原文相同。