gpt4 book ai didi

ios - 如何快速隐藏 UIPopoverPresentationController 的模糊?

转载 作者:搜寻专家 更新时间:2023-11-01 06:01:29 25 4
gpt4 key购买 nike

我已经为 UIButton 实现了弹出框:

    @objc func showList(sender: AnyObject?) {

guard let buttonView = sender?.value(forKey: "view") as? UIButton else { return }
guard let popVC = R.storyboard.first.VC() else { return }
popVC.modalPresentationStyle = .popover
let popOverVC = popVC.popoverPresentationController
popOverVC?.delegate = self
popOverVC?.sourceView = buttonView
popOverVC?.sourceRect = CGRect(x: 0, y: 190, width: 0, height: 0)
popOverVC?.permittedArrowDirections = .init(rawValue: 0)

popVC.preferredContentSize = CGSize(width: 150, height: 250)

showedViewController.present(popVC, animated: true, completion: nil)
}


extension VCInteractor: UIPopoverPresentationControllerDelegate {

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
}

它运行良好,但我需要一个修复 - 我想为我的弹出窗口隐藏 UIVisualEffectBackdropView(它就像我的 UITableViewController 下的模糊)。所以,我找不到任何关于如何禁用(隐藏)这个模糊的信息,你有什么想法吗?

最佳答案

我已经解决了自定义类的问题

class PopoverBackgroundView: UIPopoverBackgroundView {

override init(frame: CGRect) {
super.init(frame: frame)
self.layer.shadowColor = UIColor.clear.cgColor

}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override static func contentViewInsets() -> UIEdgeInsets {
return UIEdgeInsets.zero
}

override static func arrowHeight() -> CGFloat {
return 0
}

override var arrowDirection: UIPopoverArrowDirection {
get { return UIPopoverArrowDirection.down }
set {
setNeedsLayout()
}
}

override var arrowOffset: CGFloat {
get { return 0 }
set {
setNeedsLayout()
}
}
}

然后我就这样添加了

popOverVC?.popoverBackgroundViewClass = PopoverBackgroundView.self

就这样

关于ios - 如何快速隐藏 UIPopoverPresentationController 的模糊?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48791090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com