首页 > 系统 > iOS > 正文

iOS中常用设置返回按钮

2020-07-26 03:01:29
字体:
来源:转载
供稿:网友

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表