【发布时间】:2021-12-16 17:45:57
【问题描述】:
我正在处理自定义标签栏按钮的东西,想知道如何使用视图的高度或以编程方式向上移动按钮。
我有这个加号按钮,我想从底部向上移动 10pt。
let newButton = UIButton(frame: CGRect(x: 0, y: 0, width: 65, height: 65))
newButton.imageView?.contentMode = .scaleAspectFit
newButton.contentHorizontalAlignment = .fill
newButton.contentVerticalAlignment = .fill
var newButtonFrame = newEventButton.frame
newButtonFrame.origin.y = view.bounds.height - 65 - 10
所以上面的代码在 iPhone 没有 Home 键槽口的情况下有效。比如获取视图的高度并减去按钮高度和 10。
我想将按钮从标签栏底部向上移动,那么我怎样才能将屏幕的高度直到标签栏底部,这在有/没有 Home Notch 的情况下都适用?
【问题讨论】:
-
您在寻找 safeAreaEdges 吗?