美文网首页
iOS11新特性

iOS11新特性

作者: action爱生活 | 来源:发表于2018-03-22 14:22 被阅读25次

[TOC]

iOS11 大标题

// 导航控制器的`prefersLargeTitles`为大标题的总开关
navigationController?.navigationBar.prefersLargeTitles = true
        
// 各个控制器可以自己通过 largeTitleDisplayMode,如果导航控制器的 `prefersLargeTitles` 为 NO,largeTitleDisplayMode 将没有效果
navigationItem.largeTitleDisplayMode = .never
image.png

iOS11 导航栏搜索框

    let searchResultsVC = SearchResultTabelViewVC(nibName: nil, bundle: nil)
    lazy var searchController: UISearchController = {
        let vc = UISearchController(searchResultsController: searchResultsVC)
        vc.searchResultsUpdater = self.searchResultsVC
        
        vc.hidesNavigationBarDuringPresentation = true
        vc.dimsBackgroundDuringPresentation = true
        
        vc.searchBar.placeholder = "搜索设备"
        vc.searchBar.enablesReturnKeyAutomatically = false
        vc.searchBar.sizeToFit()
        
        return vc
    }()

navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
image.png image.png

iOS11 Safe Area Insets

additionalSafeAreaInsets = UIEdgeInsets(top: 100, left: 0, bottom: 100, right: 100)
image.png

UITableView separatorInsetReference

image.png
image.png
        tableView.estimatedRowHeight = 0
        tableView.estimatedSectionHeaderHeight = 0
        tableView.estimatedSectionFooterHeight = 0
        
        tableView.separatorInsetReference = .fromAutomaticInsets
        tableView.separatorInset.left = 60

UITableViewCell 左划、右划

    // iOS11 UITableViewCell 左划
    override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        let action = UIContextualAction(style: .normal, title: "收藏") { (action, view, completionHandler) in
            // 执行收藏操作
            // ...
            completionHandler(true)
        }
        action.image =  imageLiteral(resourceName: "favorite")
        action.backgroundColor = UIColor.red
        
        let configuration = UISwipeActionsConfiguration(actions: [action])
        
        return configuration
    }
    
    // iOS11 UITableViewCell 右划
    override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        let action = UIContextualAction(style: .destructive, title: "删除") { (action, view, completionHandler) in
            // remove item
            // ...
            completionHandler(true)
        }
        
        let configuration = UISwipeActionsConfiguration(actions: [action])
        
        return configuration
    }

代码见

https://github.com/action456789/iOS11Demo

相关文章

  • iOS 11新特性 - LargeTitle

    更新了iOS11之后,系统APP大量使用了新的UI风格,那就是iOS11的新特性-Large Title和新的Se...

  • iOS11新特性

    2018-6-26来源:http://iphone.tgbus.com/tutorial/use/201706/2...

  • iOS11新特性

    [TOC] iOS11 大标题 iOS11 导航栏搜索框 iOS11 Safe Area Insets UITab...

  • iOS11新特性

    前言 虽然 WWDC 是一个开发者会议,但是 Keynote 并不是专门针对我们开发者的,它还承担了公司状况说明,...

  • IOS11新特性

    新增框架 Core ML:负责简化和集成机器学习的框架 ARKit:用来创建增强现实 (AR) 应用 Vision...

  • ios11中 navigationbar + uisearchc

    我的情况是希望使用iOS11的新特性largetitle,所以我在appdelegate中设置了全局开启此特性,代...

  • iOS 11 导航栏问题

    前言 iOS11导航栏除了新加入了largeTitles和searchController两个新特性,可能是加入l...

  • iOS11 新特性,如何适配iOS11(一)

    这几天抽空把WWDC的Session看了一些,总结了一些iOS11新的特性,希望对于帮助我们适配iOS11有所帮助...

  • iOS11 SDK新特性- DeviceCheck

    iOS11 SDK新特性- DeviceCheck 通过使用DeviceCheck,你能够在某种程度上追踪到这个手...

  • iOS11新特性prefersLargeTitles

    在iOS11中有一个新特性,可以设置导航控制器导航条的prefersLargeTitles属性,当设置这个属性为Y...

网友评论

      本文标题:iOS11新特性

      本文链接:https://www.haomeiwen.com/subject/afsaqftx.html