创建 iPhone/iOS8 弹出菜单(窗口)
基本步骤
添加视图:主视图与弹出视图
关联视图
配置弹出视图
编码实现:弹出菜单样式及控制器委托
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "popoverSegue" {
let popoverViewController = segue.destinationViewController as UIViewController
popoverViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
popoverViewController.popoverPresentationController!.delegate = self
}
}
编码实现:利用弹出视图控制器委托方法,定制弹出菜单的样式
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
运行
参考
- iPad Style Popovers on the iPhone with Swift
- Adding a Segue Between Scenes in a Storyboard
- UIPopoverPresentation
- UIPopoverPresentationDelegate
- UIModalPresentationStyle
- adaptivePresentationStyleForPresentationController
- prepareForSegue
- destinationViewController
版权声明:
作者:莫不逢
出处:http://www.cnblogs.com/sitemanager/
Github:https://github.com/congjf
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。