//添加前往按鈕 -(void)backBtn{ UIButton *backBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 10, 60, 20)]; [backBtn setTitle:@"前往" forState:UIControlStateNormal]; backBtn.titleLabel.font=[UIFont systemFontOfSize:12]; backBtn.imageEdgeInsets=UIEdgeInsetsMake(2,2,2,2); [backBtn setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal]; [backBtn addTarget:self action:@selector(backto) forControlEvents:UIControlEventTouchDown]; UIBarButtonItem *leftBtn=[[UIBarButtonItem alloc]initWithCustomView:backBtn]; UIBarButtonItem *flexBtn=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; flexBtn.width=-10;//負數往左移,正數往右移 self.navigationItem.leftBarButtonItems=@[flexBtn,leftBtn]; } //前往按鈕 -(void)backto{ [self dismissViewControllerAnimated:YES completion:^{ }]; }
以上所述是本站給大家引見的IOS中常用設置前往按鈕,希望對大家有所協助,假如大家有任何疑問請給我留言,本站會及時回復大家的。在此也十分感激大家對本站網站的支持!
【iOS中常用設置前往按鈕】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!