1.UISearchController
设置UISearchController上取消按钮的文字格式时 UISearchController.searchBar.setValue(“取消”, forKey:"_cancelButtonText")这是未更新之前的写法更新后不能这么写 会直接崩溃,更新之后的写法 UISearchController.searchBar.setValue(“取消”, forKey:“cancelButtonText”)
模态弹出默认交互改变
iOS 13 的 presentViewController 默认有视差效果,模态出来的界面现在默认都下滑返回。 一些页面必须要点确认才能消失的,需要适配。如果项目中页面高度全部是屏幕尺寸,那么多出来的导航高度会出现问题。
// Swift
self.modalPresentationStyle = .fullScreen
// Objective-C
self.modalPresentationStyle = UIModalPresentationFullScreen;
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(btton)
btton.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
}
lazy var btton:UIButton = {
let button = UIButton()
button.setTitle("跳转页面2", for: .normal)
button.setTitleColor(UIColor.black, for: .normal)
button.addTarget(self, action: #selector(click), for: .touchUpInside)
return button
}()
@objc func click(){
let second = ViewController2()
second.modalPresentationStyle = .fullScreen
second.bao = { (str) -> Void in
print(str)
self.btton.titleLabel?.text = str
}
self.present(second, animated: false, completion: nil)
}
}
UIViewController 增加一个了属性 isModalInPresentation,默认为 false,当该属性为 false 时,用户下拉可以 dismiss 控制器,为 true 时,下拉不可以 dismiss控制器。