我想在我的ios应用程序中实现这样的东西:

我想要一个透明的前景与类似于“请启用蓝牙继续使用这个应用程序”的警告信息在我的ios应用程序中。如何在我的应用程序中实现类似的行为?
发布于 2020-02-28 09:49:22
var vc: BannerViewController!
func addBanner(){
vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "BannerViewController")
UIApplication.shared.keyWindow?.addSubview(vc.view)
let sv = vc.view.superview!
vc.view.translatesAutoresizingMaskIntoConstraints = false
let constrainst = [
vc.view.topAnchor.constraint(equalTo: sv.topAnchor),
vc.view.leadingAnchor.constraint(equalTo: sv.leadingAnchor),
vc.view.bottomAnchor.constraint(equalTo: sv.bottomAnchor),
vc.view.trailingAnchor.constraint(equalTo: sv.trailingAnchor)
]
vc.view.isUserInteractionEnabled = true
vc.view.backgroundColor = UIColor.red
NSLayoutConstraint.activate(constrainst)
}
func removeBanner(){
vc.view.removeFromSuperview()
vc = nil
}以上功能可以帮助您实现您想要的。基本上在故事板上设计你的横幅。然后在类级别上有一个变量。当在该回调中关闭蓝牙时,调用addBanner函数,并在蓝牙的回调函数中打开removeBanner函数。
https://stackoverflow.com/questions/60448272
复制相似问题