【发布时间】:2021-10-18 04:43:49
【问题描述】:
我想从标签栏上方的特定控制器(MyController)附加一个视图,但我的问题是如何从 MyController 计算标签栏的高度,以便我可以将 y 位置指定给我的自定义视图。我正在尝试使用 statusBarFrame 来实现,但它不起作用。如果有人有什么想法,请帮助我。
let timerView = UINib(nibName: "WorkoutTimer", bundle: nil).instantiate(withOwner: nil, options: nil).first as? WorkoutTimer
let window = UIApplication.shared.windows.last
if let timerView = timerView {
let screenSize = UIScreen.main.bounds
let screenHeight = screenSize.height
let screenWidth = screenSize.width
let statusbarHeight = UIApplication.shared.statusBarFrame.height
let yPosition = screenHeight - ((statusbarHeight) + 50)
timerView.frame = CGRect(x: 0, y: yPosition, width: screenWidth, height: 50)
window?.addSubview(timerView)
}
【问题讨论】:
-
为什么你没有被 tabBar y 框架。
-
但是如何从 MyController 访问 tabBar