Ios Swift 5 Xcode 10.3如何设置背景透明
我想创建一个自定义警报。因此,我插入了一个具有一定宽度和高度的内容视图,剩余区域我希望看起来很暗 下面的想法我已经尝试过了,但没有运气 1-在故事板中,我设置背景自定义颜色黑色和不透明度35%。但几秒钟后,背景变黑了 2-还尝试使用以下代码在UIViewController中设置背景不透明度,但不起作用Ios Swift 5 Xcode 10.3如何设置背景透明,ios,uiview,uiviewcontroller,swift5,xcode10.3,Ios,Uiview,Uiviewcontroller,Swift5,Xcode10.3,我想创建一个自定义警报。因此,我插入了一个具有一定宽度和高度的内容视图,剩余区域我希望看起来很暗 下面的想法我已经尝试过了,但没有运气 1-在故事板中,我设置背景自定义颜色黑色和不透明度35%。但几秒钟后,背景变黑了 2-还尝试使用以下代码在UIViewController中设置背景不透明度,但不起作用 view.backgroundColor = UIColor.black.withAlphaComponent(0.35) 任何帮助都将不胜感激。提前谢谢 将ViewController显示为
view.backgroundColor = UIColor.black.withAlphaComponent(0.35)
任何帮助都将不胜感激。提前谢谢
将ViewController显示为OverCurrentContext以查看父ViewController
let popupVc : PopupVC = self.storyboard?.instantiateViewControllerWithIdentifier("PopupVC") as! PopupVC
popupVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.presentViewController(popupVc, animated: true, completion: nil)
将ViewController显示为OverCurrentContext以查看父ViewController
let popupVc : PopupVC = self.storyboard?.instantiateViewControllerWithIdentifier("PopupVC") as! PopupVC
popupVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.presentViewController(popupVc, animated: true, completion: nil)
我想与大家分享我的工作经验。我使用的是Xcode 10.3和Swift 5 步骤1-在故事板中,我设置UIView背景自定义颜色黑色和不透明度35% 步骤2-使用下面的代码块显示ViewController
let popupVc : VCAlertMPIN = self.storyboard?.instantiateViewController(withIdentifier: "VCAlertMPIN") as! VCAlertMPIN
popupVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.present(popupVc, animated: true, completion: nil)
我想分享我的工作。我使用的是Xcode 10.3和Swift 5 步骤1-在故事板中,我设置UIView背景自定义颜色黑色和不透明度35% 步骤2-使用下面的代码块显示ViewController
let popupVc : VCAlertMPIN = self.storyboard?.instantiateViewController(withIdentifier: "VCAlertMPIN") as! VCAlertMPIN
popupVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.present(popupVc, animated: true, completion: nil)
我不确定是否有足够的数据来回答它,你能提供更多的代码吗?我不确定是否有足够的数据来回答它,你能提供更多的代码吗?我用你的代码做了一些改进,现在它工作得很好。我用你的代码做了一些改进,现在它工作得很好