gpt4 book ai didi

ios - 如何使 Popup ViewController 的背景透明?

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

我有一个 ViewController 作为弹出窗口来选择 UIDatePicker 上的日期。但是,当这个弹出窗口打开时,背景会被新的背景色覆盖。我尝试选择颜色的不透明度,但这不起作用。我使用 UILabel 来处理点击并打开一个新的 ViewController。

override func viewDidLoad() {
super.viewDidLoad()

let tapDateSelectExpiration = UITapGestureRecognizer(target: self, action: #selector(handleSelectDateExpiration))
let tapDateSelectValidity = UITapGestureRecognizer(target: self, action: #selector(handleSelectDateValidity))
let tapDateSelectOrder = UITapGestureRecognizer(target: self, action: #selector(handleSelectDateOrder))

lblDataPedido.isUserInteractionEnabled = true
lblDataValidade.isUserInteractionEnabled = true
lblDataExpiracao.isUserInteractionEnabled = true

lblDataPedido.addGestureRecognizer(tapDateSelectOrder)
lblDataValidade.addGestureRecognizer(tapDateSelectValidity)
lblDataExpiracao.addGestureRecognizer(tapDateSelectExpiration)
}

@objc func handleSelectDateExpiration(_ sender : UILabel) {
print("handleSelectDateExpiration")
var vcSelectDate = self.storyboard?.instantiateViewController(withIdentifier: "ViewControllerSelectDate") as! ViewControllerSelectDate
vcSelectDate.typeDate = "DateExpiration"
self.present(vcSelectDate,animated: true,completion: nil)
}

// Other funcs as above.

主要布局:

MainLayout

背景不透明的 DatePicker 布局:

DatePicker layout with backgroud not transparent

Storyboard:

enter image description here

最佳答案

你可以试试

let vc = self.storyboard?.instantiateViewController(withIdentifier: "dateView") as! dateViewController

vc.delegate = self

vc.providesPresentationContextTransitionStyle = true;

vc.definesPresentationContext = true;

vc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext

self.present(vc, animated: false, completion: nil)

然后像这样选择透明背景

enter image description here

或在 IB 中

enter image description here

关于ios - 如何使 Popup ViewController 的背景透明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50156123/

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