我的應用程式有一個 SettingsVC,它包含一個 TableView,詳細說明我的應用程式的所有可用選項。我想在用戶點擊這些選項之一時顯示一個彈出視圖,以避免將用戶帶到另一個 VC。我目前已經在應用程式的其他部分實作了彈出視圖,但是嘗試從 SettingsVC 呈現它時出現問題,似乎邊界是 tableView 的整個大小,而不是當前螢屏上的大小,所以如果我向下滾動,彈出視窗會一直向上顯示......任何想法。這是我的彈出視圖的設定方法。animateIn() 方法是呈現彈出視圖和模糊視圖。
func setUpPickerView(){
blurView.bounds = self.view.bounds
pickerView.bounds = CGRect(x: 0, y: 0, width: self.view.bounds.width * 0.75, height: self.view.bounds.height * 0.45)
pickerView.layer.cornerRadius = 15.0
pickerView.layer.cornerRadius = 15.0
animateIn(desiredView: blurView)
animateIn(desiredView: pickerView)
tableView.isUserInteractionEnabled = false
blurView.alpha = 0.6
}
uj5u.com熱心網友回復:
該bounds視圖的是視圖內的坐標系。在frame其中該視圖顯示在它的父視圖定義的坐標系統。您的代碼只看到了bounds所以框架可能默認為螢屏頂部。我懷疑你想要這樣的東西:
blurView.frame = self.view.bounds
pickerView.frame = CGRect(
x: (blurView.bounds.size.height - self.view.bounds.width * 0.75) / 2
y: (blurView.bounds.size.width - self.view.bounds.height * 0.45) / 2
width: self.view.bounds.width * 0.75
height: self.view.bounds.height * 0.45)
但是你真的可能應該做的是建立blurView和pickerView使用限制,然后確定它們的位置。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/363809.html
