您好,登錄后才能下訂單哦!
iOS 上UINavigationController視圖壓棧形式,可以在當前視圖無限制push許多視圖,然而一些會覺得自帶的push按鈕不夠美觀,而且當上的上一個頁面title很長的時候,那個返回按鈕就很長,怎樣定義一個自己返回按鈕呢?向第三幅圖片一樣。。。
需要push的視圖里面定義一個事件
- (IBAction)pushVC:(id)sender { NavViewController *navVC = (NavViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"NavViewController"]; navVC.title = NSLocalizedString(@"設置", nil); [self.navigationController pushViewController:navVC animated:YES]; }
替換返回按鈕,定義自定義按鈕
- (void)viewDidLoad { [super viewDidLoad]; UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; backBtn.frame = CGRectMake(0, 0, 44, 44); [backBtn setImage:[UIImage p_w_picpathNamed:@"back.png"] forState:UIControlStateNormal]; [backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn]; self.navigationItem.leftBarButtonItem = backItem; // Do any additional setup after loading the view. } -(void)doBack:(id)sender { [self.navigationController popViewControllerAnimated:YES]; }
×××地址:https://github.com/XFZLDXF/XFNavBarBtn
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。