你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS中常用設置返回按鈕

iOS中常用設置返回按鈕

編輯:IOS開發綜合

//添加返回按鈕
-(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中常用設置返回按鈕,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對本站網站的支持!

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved