I add a tab bar to view controller manually, this is not a tabBarController
, because I only want the tab bar UI, not the tab bar function
I want to click on tab bar and show new ViewController
, but I cannot do that in storyBoard
If I use this method, xcode prompt me Value of type 'UITabBarItem' has no member 'isUserInteractionEnabled'
and Value of type 'UITabBarItem' has no member 'addGestureRecognizer'
How can I click a UITabBarItem?
How to make a UILabel clickable?
@IBOutlet weak var setting: UITabBarItem!
@IBOutlet weak var activity: UITabBarItem!
@IBOutlet weak var profile: UITabBarItem!
@IBOutlet weak var connect: UITabBarItem!
@IBOutlet weak var scanner: UITabBarItem!
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(tapFunction))
setting.isUserInteractionEnabled = true
setting.addGestureRecognizer(tap)
activity.isUserInteractionEnabled = true
activity.addGestureRecognizer(tap)
profile.isUserInteractionEnabled = true
profile.addGestureRecognizer(tap)
connect.isUserInteractionEnabled = true
connect.addGestureRecognizer(tap)
scanner.isUserInteractionEnabled = true
scanner.addGestureRecognizer(tap)
}
@objc func tapFunction(sender:UITapGestureRecognizer) {
print("tap working")
}