gpt4 book ai didi

ios - TapGesture 在 tabBar 下不起作用

转载 作者:行者123 更新时间:2023-11-30 11:28:20 25 4
gpt4 key购买 nike

我有一个“经典应用程序”,带有 3 个 ViewController 和一个用于更改 ViewController 的 tabBar。

在我的第一个 ViewController 上,我有一个在整个屏幕上显示 UIView 的按钮,因此我使用 setTabBarVisible 函数隐藏 tabBar :

extension UIViewController
{

func setTabBarVisible(visible: Bool, animated: Bool)
{
//* This cannot be called before viewDidLayoutSubviews(), because the frame is not set before this time

// bail if the current state matches the desired state
if (isTabBarVisible == visible) { return }

// get a frame calculation ready
let frame = self.tabBarController?.tabBar.frame
let height = frame?.size.height
let offsetY = (visible ? -height! : height)

// zero duration means no animation
let duration: TimeInterval = (animated ? 0.3 : 0.0)

// animate the tabBar
if frame != nil
{
UIView.animate(withDuration: duration)
{
self.tabBarController?.tabBar.frame = frame!.offsetBy(dx: 0, dy: offsetY!)
return
}
}
}

var isTabBarVisible: Bool
{
return (self.tabBarController?.tabBar.frame.origin.y ?? 0) < self.view.frame.maxY
}
}

工作正常,tabBar 已隐藏,我可以看到所有 UIVIew。问题是,我在 UIView 底部有一个 UILabel (在我通常显示 tabBar 的地方),并且我无法在 UILabel 上使用 TapGesture,什么也没有发生。(如果我在其他地方显示标签,UITapGesture 效果很好。)

我尝试将 tabBar 的 zPosition 设置为 0,将 UIView 的 zPosition 设置为 1,但这也不起作用。

如何让我的标签在 View 底部可点击?

最佳答案

检查 UILabel.isUserInterration = 启用

确保隐藏选项卡栏时,特定 View Controller 在底部栏属性下未选择。 See atteh imnage.

您也可以尝试以编程方式进行操作,例如

ViewController.edgesForExtendedLayout = UIRectEdge.top

关于ios - TapGesture 在 tabBar 下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50507542/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com