添加自定义按钮的UITabBarController(中间添加按钮)
问题描述:
我试图做一些图片我犯了一个自定义的标签栏,我遇到了一些麻烦。我试图添加一个按钮到标签栏,它似乎我不能这样做。我想要做这样的事情:添加自定义按钮的UITabBarController(中间添加按钮)
然后添加一些动画给该按钮。我如何去添加该按钮?我需要继承UITabBarController吗?谢谢!
答
您应该实现的UITabBarControllerDelegate
的委托方法:
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if viewController == (self.tabBarController?.viewControllers?[theIndexOfTheButton])! {
// do my stuffs here
return false
}
return true
}
不要忘记设置self.tabBarController?.delegate = self
试试这个https://github.com/Ramotion/animated-tab-bar –
@rajeshkumarR这看起来不错,我想出了如何将按钮添加到视图,但它几乎没有这个好!这会允许我添加一个按钮吗?我希望按钮执行一个操作,而不一定只是切换选项卡/视图 – thelegendary3