我正在尝试在自定义alertView中插入tableview。我需要实现与默认警报相同的样式。从调试视图层次结构我几乎复制了样式,但我无法弄清楚Apple如何设置模糊效果。我的自定义提醒视图层次结构here
我试图以编程方式插入模糊视图,但结果太暗,太白或相同的透明度
let blur = UIVisualEffectView(effect: UIBlurEffect(style: .all of them))
blur.frame = self.alertView.frame
blur.isUserInteractionEnabled = false
self.view.insertSubview(blur, at: 1)
答案 0 :(得分:0)
他们有几个不同的对话框,但这样的事情是一个很好的起点:
/// Composite view of blur + vibrancy + white bg color blending
/// which recreates the Apple alert dialog effect
lazy var dialogView: UIVisualEffectView = {
let blur = UIBlurEffect(style: .regular)
let blurView = UIVisualEffectView(effect: blur)
let vibrancy = UIVibrancyEffect(blurEffect: blur)
let vibrantView = UIVisualEffectView(effect: blurView.effect)
vibrantView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurView.contentView.addSubview(vibrantView)
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurView.layer.cornerRadius = 20
blurView.layer.masksToBounds = true
let blendView = UIView()
blendView.backgroundColor = .white
blendView.alpha = 0.5
blendView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurView.contentView.addSubview(blendView)
return blurView
}()
然后只需将其添加到您的视图和约束w / autolayout。
答案 1 :(得分:-1)
试试这段代码 -
{ "_id":1,
"s_id":121211,
"data_detail":{
"name":"John",
"phone_number":08089320xxx,
"city":"ABC"
}
}
希望这有帮助!