選項卡欄中間的選項卡角外 [英] tabbar middle tab out of tabbar corner
本文介紹了選項卡欄中間的選項卡角外的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想制作一個包含5個選項卡項的選項卡欄。我希望中間的那個(第三個)在選項卡欄的角之外,這可能很難理解,因此我決定添加屏幕截圖
我想做一些你可以在上面看到的東西,但我不知道這是怎么可能的。 如果您能推薦我這樣做,我將不勝感激。
推薦答案
創建UITabBarControler類并將其分配給TabBarControler.
初始化變量
let button = UIButton.init(type: .custom)
然后在view DidLoad
中override func viewDidLoad() {
super.viewDidLoad()
button.setImage(UIImage(named: "IMAGE_NAME_FROM_ASSETS"), for: .normal)
button.backgroundColor = UIStyle.Color.CameraBG
button.layer.cornerRadius = 40
button.addShadow(offset: CGSize(width: 5, height: 5), color: UIStyle.Color.CameraShadow, radius: 5, opacity: 0.1)
button.addTarget(self, action: #selector(pressedAction(_:)), for: .touchUpInside)
self.view.insertSubview(button, aboveSubview: self.tabBar)
}
在您的班級中添加viewDidLayoutSubview
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// safe place to set the frame of button manually
button.frame = CGRect.init(x: self.tabBar.center.x - 40, y: self.view.bounds.height - 100, width: 80, height: 80)
}
要執行的操作單擊按鈕
@objc func pressedAction(_ sender: UIButton) {
// do your stuff here
let nc = UINavigationController(rootViewController: YOURVC.storyboardInstance())
nc.modalPresentationStyle = .fullScreen
present(nc, animated: true, completion: nil)
}
這篇關于選項卡欄中間的選項卡角外的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持IT屋!
查看全文