我想在swift2,x-code 7.3中创建一个像foursquare中的弹出菜单:
我正在使用此代码
//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
,但属性是不可改变的:
这些是故事板属性:
编辑:我设法修复它,我没有意识到故事板设置窗口大小有限制。我已经创建了一个高度约束的出口,只是从修复我的问题的代码中改变它的值。答案 0 :(得分:0)
Y位置是其位于Y轴上的位置,因此您需要将其设置为:
y: (self.view.frame.size.height/3) * 2.0,