I am working on application that is more likely a tabBarController
application. But I can not use the tabBarController
because I need a custom ta
For ios 9.0+ use UIStackView in Horizontal direction and create a xib and named it CustomTabBarView
CustomTabBarView.Xib
Create Another View CustomTabBarItem.
CustomTabBarItem.xib
create CustomTabBarItem.swift file for implement functionality of TabItem
class CustomTabItem: UIView {
//MARK:- IBOutlets
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var itemTitle: SelectableLabel!
@IBOutlet weak var topButton: UIButton!
//MARK:- Variables
var isSelected: Bool = false {
didSet {
self.itemImage.image = CommonFunctions.getTabItemImage(isSelected: isSelected, tag: topButton.tag)
itemTitle.isSelected = isSelected
if isSelected {
self.backgroundColor = UIColor.appDarkBlueColor
}
else {
self.backgroundColor = UIColor.appWhiteColor
}
}
}
//MARK:- IBActions
@IBAction func onClickButton(_ sender: Any) {
}
}
In TabBarViewController Implement This Code
func createCustomTabBarView(tabItemCount: Int){
customTabBarView = Bundle.main.loadNibNamed("CustomTabBarView", owner: nil, options: nil)?.last as! UIView
customTabBarView.frame = CGRect(x: 0, y: self.view.frame.height - self.tabBar.frame.height, width: self.tabBar.frame.width, height: self.tabBar.frame.size.height)
self.view.addSubview(customTabBarView)
var stackView = UIStackView()
for subView in customTabBarView.subviews{
if subView is UIStackView {
stackView = subView as! UIStackView
}
}
for i in 0..