ios - 如何更改 UIToolbar 高度?

标签 ios swift uitoolbar

<分区>

我想在 Navigation Controller 中更改 UIToolbar 的高度,但我无法使用 Xcode 7.3 和 iOS 9 快速完成此操作。我尝试在 viewDidLoad 中使用 CGRectMake 设置框架,但没有成功.还尝试初始化自定义 UIToolbar(),但高度保持不变。

编辑:

根据其中一个答案,我尝试选择工具栏,按下控制键并再次选择工具栏,但我得到的结果显示在下面的屏幕截图中:

Screenshot

最佳答案

根据您是否使用 Storyboard,有 2 个选项。

选项 1:使用 Storyboard

1) 转到您的 Storyboard 并从您选择的工具栏中按住 Ctrl 并再次单击您的工具栏,就像您正在分配 IBAction 一样。然后你会得到以下内容:

(对第一张图片的质量感到抱歉;因为我无法在按住 ctrl 的情况下进行屏幕截图,所以不得不用手机拍照)

enter image description here enter image description here

2) 然后按高度获取约束并更改值:

enter image description here

选项 2:例如使用 Swift 55 像素高度

 yourToolBar.frame = CGRect(x: 0, y: view.frame.size.height - 55, width: view.frame.size.width, height: 55)

关于ios - 如何更改 UIToolbar 高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39074490/

相关文章:

ios - 从第一个空格拆分 NSString

ios - 后台定位服务在一段时间内停止工作

ios - Swift:使用评估Javascript

ios - 为每个按钮添加声音

SwiftUI - 使用 'pushViewController' 时出现 fatal error

ios - 当 UITableViewController 嵌入到 UIViewController 中的容器中时,额外的表格单元格

iphone - 如何在 UIToolbar 上拥有多行项目?

ios - 在工具栏/标签栏之间交替

ios - 数据被检索为project.model而不是swift ios中的元素

iphone - 将 UIBarButtonItems 添加到工具栏时出现问题