前言
本文主要介绍了关于iOS11适配及导航栏影藏返回文字的解决方法,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
一、iOS11适配工作
这是一篇 WWDC Session 204 "Updating Your App for iOS 11" 的总结,里面的内容涉及到了产品、设计以及开发需要了解的内容。
在 "iPad" 以及 "iPhone 的 Landscape" 下, UITabBarItem 图片和文字并排排列了,并且长按 UITabBarItem 会有一个大的 HUD 显示在中间
通过设置 UIBarItem.largeContentSizeImage 可以设置 Tabbar 长按之后显示在中间的图片
(这个功能我在 Beta 2 中没有试出来,只能截取官方的图片)

iOS 11 为我们带来了 "Large Title",效果如下,当 "ScrollView" 向上滑动时,"Large Title" 会跟着改变, 效果如下:

"SearchBar" 被移植到了 "NavigationBar" 上面, 提供两种模式,一种是滚动后隐藏 searchBar(如上图), 另外一种就是保留 searchBar 在 Navigation 上。通过以下代码控制
navigationItem.hidesSearchBarWhenScrolling = false
UIToolbar, UINavigationBar 支持 Auto Layout
UIView.layoutMargins 被扩展到了 UIView.directionalLayoutMargins, 支持 Right to Left 语言(和我们关系不大,除非某天我们进军中东的某些国家了)。并且,这两个属性会互相同步
UIViewController 添加 systemMinimumLayoutMargins 属性(说实话,我们布局真的很少用到这个东西,不过可以作为了解)
新增 UIView.safeAreaLayoutGuide,同时废弃 UIViewController.topLayoutGuide 和 UIViewController.bottomLayoutGuide。如果你之前处理过 UINavigationBar 的translucent,你就会发现 topLayoutGuide 的表现只能用差强人意来形容,希望这次新增的 safAreaLayoutGuide 能够彻底改变这个现状
///safeAreaLayoutGuide 取代 topLayoutGuide 的代码
//subview.topAnchor.constraint(equalTo: self.topLayoutGuide.bottomAnchor).isActive = true
subview.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true










