3
我有一个UITabBarController
与TabBar中间的自定义按钮。但是如果我设置hidesBottomBarWhenPushed = true
,我会发现一个奇怪的行为。如何在Swift 3中隐藏TabBarController上的自定义按钮?
func setupMiddleButton() {
let menuButton = UIButton(frame: CGRect(x: 0, y: 0, width: 48, height: 48))
var menuButtonFrame = menuButton.frame
menuButtonFrame.origin.y = view.bounds.height - menuButtonFrame.height
menuButtonFrame.origin.x = view.bounds.width/2 - menuButtonFrame.size.width/2
menuButton.frame = menuButtonFrame
menuButton.layer.cornerRadius = menuButtonFrame.height/2
view.addSubview(menuButton)
menuButton.setImage(UIImage(named: "updatemoment"), for: .normal)
menuButton.addTarget(self, action: #selector(menuButtonAction), for: .touchUpInside)
view.layoutIfNeeded()
}
func menuButtonAction() {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: UINavigationController = storyboard.instantiateViewController(withIdentifier: "NewPostID") as! UINavigationController
self.present(vc, animated: true, completion: nil)
print("segue success")
}
如何解决这个问题:
我编程斯威夫特3.
这里是我的代码来创建自定义中间按钮创建UITabBarController
?我想要中间的按钮留在BottomBar
。
在此先感谢。
工程就像一个魅力。非常感谢你。 – Badrinath