![](/img/trans.png)
[英]Unwanted UIView over UICollectionViewCell (TapGesture Doesn't work )
[英]TapGesture doesn't work under tabBar
我有一个带有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,但这也不起作用。
如何在视图底部使标签可点击?
检查UILabel.isUserInterration =启用
确保隐藏标签栏时,取消选择“垂直视图控制器在底部栏下”属性。 参见atteh imnage。
您可以通过编程方式尝试
ViewController.edgesForExtendedLayout = UIRectEdge.top
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.