iOS10以后的新技术Swifty CodingWWDC17

iOS 11 适配工作

2017-06-30  本文已影响4003人  Pikachuqiu

这是一篇 WWDC Session 204 "Updating Your App for iOS 11" 的总结,里面的内容涉及到了产品、设计以及开发需要了解的内容。

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

蓝色区域即:UIView.safAreaLayoutGuide

    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
    }
上一篇下一篇

猜你喜欢

热点阅读