2016-07-25 111 views
0

我想創建一個彈出菜單就像在swift2四角的大小,X-代碼7.3:無法處理酥料餅

enter image description here

我使用這個代碼

//Create Pop up Menu 
func setAnimatedMenu(identifier : String)-> ViewController{ 

    let storyboard : UIStoryboard = UIStoryboard(
     name: "Main", 
     bundle: nil) 
    let menuViewController: ViewController = storyboard.instantiateViewControllerWithIdentifier(identifier) as! ViewController//filters 

    menuViewController.modalPresentationStyle = .OverFullScreen //played with this and tried every different styles 
    menuViewController.preferredContentSize = CGSizeMake(self.view.frame.width, self.view.frame.height/3) //Played with this size, nothing changes 

    let popoverMenuViewController = menuViewController.popoverPresentationController 
    popoverMenuViewController?.permittedArrowDirections = .Any 
    popoverMenuViewController?.delegate = self 

    popoverMenuViewController?.sourceView = parentViewController?.view 
    popoverMenuViewController?.sourceRect = CGRect(
     x: self.view.frame.size.width, 
     y: self.view.frame.size.height/3, 
     width: 1, 
     height: 1) //played also with this size, nothing changes 


    return menuViewController 

} 

我想要完成的是類似於圖片中的內容,在當前視圖和選項卡上彈出,但可以看到1/3的上方視圖。我只能設法完成整個屏幕,如果我在彈出窗口中滾動並將其移動到底部或頂部,我只能看到後部視圖。

我嘗試設置其preferredContentSize但是屬性unmutable:

enter image description here

這些故事板屬性:

enter image description here enter image description here

編輯:我設法解決它,我還沒有意識到故事板中設置窗口大小的限制。我創建了一個高度約束的出口,只是改變了代碼的價值,它解決了我的問題。

回答

0

Y位置是在哪裏它位於Y軸的位置,所以你需要將其設置爲:

y: (self.view.frame.size.height/3) * 2.0, 
+0

不會完全像以前一樣。什麼也沒有變。可以是故事板中的問題?編輯添加具有屬性的故事板圖像 – user3033437