当调用3D Touch Peek时,发生背景模糊,我注意到它有所不同。
例如,它在iMessage中是轻微模糊,但在FaceTime应用程序中模糊不清。
(虽然下图可能不是显示对比度的最佳示例,但您可以通过iOS 10更好地注意到它)
这是从上下文亮度自动完成的吗?背景视图亮度?窥视上下文亮度?或者我们对此有何控制权?
extension ChatTableViewController: UIViewControllerPreviewingDelegate {
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let indexPath = tableView.indexPathForRow(at: location) else { return nil }
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: ChatDetailViewController.identifier)
guard let chatDetailViewController = viewController as? ChatDetailViewController else { return nil }
chatDetailViewController.chatItem = chatItem(at: indexPath)
let cellRect = tableView.rectForRow(at: indexPath)
previewingContext.sourceRect = previewingContext.sourceView.convert(cellRect, from: tableView)
chatDetailViewController.isReplyButtonHidden = true
return chatDetailViewController
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
if let chatDetailViewController = viewControllerToCommit as? ChatDetailViewController {
chatDetailViewController.isReplyButtonHidden = false
}
show(viewControllerToCommit, sender: self)
}
}
答案 0 :(得分:3)
我正在弄乱UIViewController
的一些属性试图找出如何做到这一点,结果发现改变preferredStatusBarStyle
会改变模糊颜色。
要将偷看模糊样式从亮变为暗,您可以将preferredStatusBarStyle
从.default
更改为.lightContent
class MyViewController: UIViewController{
override var preferredStatusBarStyle: UIStatusBarStyle{
return .lightContent
}
}
这也适用于隐藏状态栏
class MyViewController: UIViewController{
override var prefersStatusBarHidden: Bool{
return true
}
override var preferredStatusBarStyle: UIStatusBarStyle{
return .lightContent
}
}