簡體   English   中英

在 Swift 中更改 UINavigationController 幀

[英]Changing UINavigationController Frame in Swift

如何更改 UINavigationController 的框架? 我正在嘗試構建一個視圖來驗證用戶的電話號碼,並希望將其顯示為彈出視圖(不是完整的工作表)並且還能夠在其上推送另一個視圖 controller。

目前此實現以工作表形式呈現,不確定為什么或如何更改它,因此它只有 320x200

func presentPhoneVerify() {
        let vc = VerifyPhoneVC(nibName: "VerifyPhoneView", bundle: nil)
        vc.view.frame = CGRect(x: 100, y: 100, width: 320, height: 200)
        let nav = UINavigationController(rootViewController: vc)
        nav.view.frame = CGRect(x: 100, y: 100, width: 320, height: 200)
        self.present(nav, animated: true, completion: nil)
    }

添加UINavigationController作為childViewController 然后設置UINavigationController的框架。 這是代碼。

func presentPhoneVerify() {
    let vc = VerifyPhoneVC(nibName: "VerifyPhoneView", bundle: nil)
    let nav = UINavigationController(rootViewController: vc)
    self.addChild(nav)
    nav.view.frame = CGRect(x: 100, y: 100, width: 320, height: 200)
    self.view.addSubview(nav.view)
    nav.didMove(toParent: self)
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM