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