iOS 11 适配工作

这是一篇 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.topLayoutGuideUIViewController.bottomLayoutGuide。如果你之前处理过 UINavigationBartranslucent,你就会发现 topLayoutGuide 的表现只能用差强人意来形容,希望这次新增的 safAreaLayoutGuide 能够彻底改变这个现状

///safeAreaLayoutGuide 取代 topLayoutGuide 的代码
//subview.topAnchor.constraint(equalTo: self.topLayoutGuide.bottomAnchor).isActive = true
subview.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true

蓝色区域即:UIView.safAreaLayoutGuide

  • UIScrollView 新增 adjustedContentInset
  • UIScrollView 新增 frameLayoutGuidecontentLayoutGuide, 目的是为了降低 ScrollView Auto Layout 的难度
  • UITabelViewCell 的 rowHeight 默认变成 UITableViewAutomaticDimension, 意味着自动算高会更普及了

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

    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
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,755评论 4 61
  • 受了伤,只能在夜晚无人静寂的时候舔舐自己的伤口。安慰自己,包扎伤口,明天继续在人面前充当开心果。
    心思单纯阅读 1,382评论 0 0
  • 前几天临睡觉时,一位许久不联系的大学校友微信上问我:“我也想开始练瑜伽了,可是不知道怎么选瑜伽馆,你能给点建议吗?...
    李小筑阅读 12,360评论 0 29
  • 今天看了《麦兜我和我妈妈》,心里不由得想,我妈妈有那么能干就好了。而我不知道的是,我妈在看cctv的时候,听着...
    小小清sandy阅读 3,280评论 0 0
  • 谁在梦边枕畔巡弋你的消息 鱼贯而出的泪滴浸透夜雨凄迷 思绪如刀磨锯于心中希望的生意 绝妙的意外堆砌起厉声的悲戚 行...
    叶落岁暮阅读 1,355评论 0 5

友情链接更多精彩内容