iOS11适配工作及导航栏影藏返回文字的解决方法

2020-01-21 02:06:58于海丽

蓝色区域即:UIView.safAreaLayoutGuide

UIScrollView 新增 adjustedContentInset

UIScrollView 新增 frameLayoutGuide 和 contentLayoutGuide, 目的是为了降低 ScrollView Auto Layout 的难度

ios11,导航栏适配,ios11适配问题,ios,导航栏返回按钮

UITabelViewCell 的 rowHeight 默认变成 UITableViewAutomaticDimension, 意味着自动算高会更普及了

UITableView 开放了 "Full Swipe", 就像删除邮件的操作一样

ios11,导航栏适配,ios11适配问题,ios,导航栏返回按钮


 func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
  return nil
 }

 func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
  let action = UIContextualAction(style: UIContextualAction.Style.destructive, title: "Delete") { (action, view, completionHandler) in
   self.tableView.beginUpdates()
   self.data.remove(at: indexPath.row)
   self.tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.left)
   self.tableView.endUpdates()
   completionHandler(true)
  }
  let configuration = UISwipeActionsConfiguration(actions: [action])
  return configuration
 }

二、导航栏影藏返回文字的解决方法

如果要只保留返回按钮的文字,不需要"返回"文字

iOS11之前,在 全局函数执行的地方使用一下代码:


// barBtn.setBackButtonTitlePositionAdjustment( UIOffset(horizontal:0 , vertical: -70), for: .default) //设置取消返回按钮的字体 

iOS11之后,我的解决办法为,在push的父页面将title设为空

例如:


self.title = "" 
self.navigationController?.pushViewController(workDetail, animated: true) 

这样的话就需要在viewWillAppear方法中每次都设置控制器的title,不然就会导致返回这个页面的时候title不见的。

综合的解决办法,手动添加一个只含返回图标的button,然后在push到目的页面的时候添加。

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对ASPKU的支持。


注:相关教程知识阅读请移步到IOS开发频道。