ios - 如何删除内容和弹出箭头之间的白色区域ios

标签 ios swift navigation popover

我准确地设置了我需要的弹出窗口的内容和大小。然而,我的内容(即使我已经在距离 0 的每一边设置了约束)和弹出窗口的箭头之间有一个白色区域。如何删除该白色区域或更改其颜色?

最佳答案

我发现这个白色区域是这个 View Controller 的导航栏。我不知道当我们将 View Controller 呈现为弹出窗口时会出现导航栏。因此,解决方案简单如下:

Swift 3:

nav.isNavigationBarHidden = true //simply hide the navigation bar

有关完整的用法示例:

//instantiation of your VC may be different
let popoverContent: BackgroundColorPaletteViewController = storyboard.instantiateViewController() 
let nav = UINavigationController(rootViewController: popoverContent)
nav.modalPresentationStyle = UIModalPresentationStyle.popover
let popover = nav.popoverPresentationController
popoverContent.preferredContentSize = CGSize(width: 200, height: 40)
popover?.delegate = self
popover?.sourceView = sender
popover?.sourceRect = sender.bounds
nav.isNavigationBarHidden = true //simply hide the navigation bar

self.present(nav, animated: true, completion: nil)

关于ios - 如何删除内容和弹出箭头之间的白色区域ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49561544/

相关文章:

ios - 如何以编程方式调整按钮动画的大小

ios - 使用Shell脚本在XCode项目中查找包标识符

swift - 如何获取目标文件格式(或文件)的 Finder "Open in app"对话框中显示的应用程序列表?

html - 导航栏后面的 CSS anchor 链接

c# - 如何使用 MVVM Light 从一个页面传递查询字符串参数并在 WP 7 中获取另一个页面

navigation - 如何导航到 Jupyter Notebook 中的不同目录?

ios - Swift 中的 UIButton - 操作不起作用

ios - 使用形状蒙版 Swift 隐藏文本

iOS - 从 UIImage 生成 URL

ios - 为什么 pickerView 不在 tableView 单元格内的文本字段中输入文本?