当前位置 : 主页 > 手机开发 > ios >

iOS中常用设置返回按钮

来源:互联网 收集:自由互联 发布时间:2021-05-10
//添加返回按钮-(void)backBtn{ UIButton *backBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 10, 60, 20)]; [backBtn setTitle:@"返回" forState:UIControlStateNormal]; backBtn.titleLabel.font=[UIFont systemFontOfSize:12]; backBtn.image

//添加返回按钮
-(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中常用设置返回按钮,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对自由互联网站的支持!

网友评论