按下时如何检测/操作选项卡栏项目

时间:2019-01-17 03:41:02

标签: ios swift xcode uitabbarcontroller uitabbar

我将UIViewController添加到了UITabBarControllerDelegate类型的ViewController中,并扩展为拥有tabBar

如何检测何时单击了import UIKit class VHomeViewController: UIViewController, UITabBarControllerDelegate { @IBOutlet weak var menuButton: UIBarButtonItem! @IBOutlet weak var navigation_header: UINavigationBar! @IBOutlet weak var tabbar_header: UITabBar! override func viewDidLoad() { super.viewDidLoad() tabbar_header.delegate = self as? UITabBarDelegate loadDesign() if revealViewController() != nil { menuButton.target = self.revealViewController() menuButton.action = #selector(SWRevealViewController.revealToggle(_:)) } } func loadDesign(){ //set background self.view.backgroundColor = UIColor(patternImage: (UIImage(named: "main_background") ?? nil)!) //navigation transparent self.navigation_header.setBackgroundImage(UIImage(), for: .default) self.navigation_header.shadowImage = UIImage() self.navigation_header.isTranslucent = true self.navigation_header.backgroundColor = .clear } func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) { print("Hello") } } 个项目?

viewController代码如下:

{{1}}

0 个答案:

没有答案