diff --git a/Demo/TabPageViewControllerDemo/AppDelegate.swift b/Demo/TabPageViewControllerDemo/AppDelegate.swift index 56e1333..b525496 100644 --- a/Demo/TabPageViewControllerDemo/AppDelegate.swift +++ b/Demo/TabPageViewControllerDemo/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/Demo/TabPageViewControllerDemo/InfiniteTabPageViewController.swift b/Demo/TabPageViewControllerDemo/InfiniteTabPageViewController.swift index 14398fb..f1a96ed 100644 --- a/Demo/TabPageViewControllerDemo/InfiniteTabPageViewController.swift +++ b/Demo/TabPageViewControllerDemo/InfiniteTabPageViewController.swift @@ -23,7 +23,7 @@ class InfiniteTabPageViewController: TabPageViewController { vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0) let vc5 = UIViewController() vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0) - tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")] + tabItems = [(vc1, "Mon.",""), (vc2, "Tue.",""), (vc3, "Wed.",""), (vc4, "Thu.",""), (vc5, "Fri.","")] isInfinity = true option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0) option.tabMargin = 30.0 diff --git a/Demo/TabPageViewControllerDemo/LimitedTabPageViewController.swift b/Demo/TabPageViewControllerDemo/LimitedTabPageViewController.swift index bcfd419..9034cc4 100644 --- a/Demo/TabPageViewControllerDemo/LimitedTabPageViewController.swift +++ b/Demo/TabPageViewControllerDemo/LimitedTabPageViewController.swift @@ -16,7 +16,7 @@ class LimitedTabPageViewController: TabPageViewController { let vc1 = UIViewController() vc1.view.backgroundColor = UIColor.white let vc2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ListViewController") - tabItems = [(vc1, "First"), (vc2, "Second")] + tabItems = [(vc1, "First",""), (vc2, "Second","")] option.tabWidth = view.frame.width / CGFloat(tabItems.count) option.hidesTopViewOnSwipeType = .all } diff --git a/Sources/TabCollectionCell.swift b/Sources/TabCollectionCell.swift old mode 100644 new mode 100755 index cc9a02d..1d3ccc5 --- a/Sources/TabCollectionCell.swift +++ b/Sources/TabCollectionCell.swift @@ -10,12 +10,13 @@ import UIKit class TabCollectionCell: UICollectionViewCell { - var tabItemButtonPressedBlock: ((Void) -> Void)? + var tabItemButtonPressedBlock: (() -> Void)? var option: TabPageOption = TabPageOption() { didSet { currentBarViewHeightConstraint.constant = option.currentBarHeight } } + var item: String = "" { didSet { itemLabel.text = item @@ -23,6 +24,38 @@ class TabCollectionCell: UICollectionViewCell { invalidateIntrinsicContentSize() } } + + var subItem: String = "" { + didSet { + subItemTitle.text = subItem + if subItem.count > 0{ + tabSubItem.isHidden = false + titleCenterY.constant = -10 + subItemHeight.constant = 15 + } + else{ + tabSubItem.isHidden = true + titleCenterY.constant = 0 + subItemHeight.constant = 0 + } + } + } + + var showSubItem : Bool = false{ + didSet { + if showSubItem{ + tabSubItem.isHidden = false + titleCenterY.constant = -10 + subItemHeight.constant = 15 + } + else{ + tabSubItem.isHidden = true + titleCenterY.constant = 0 + subItemHeight.constant = 0 + } + } + } + var isCurrent: Bool = false { didSet { currentBarView.isHidden = !isCurrent @@ -36,6 +69,13 @@ class TabCollectionCell: UICollectionViewCell { } } + @IBOutlet fileprivate weak var tabSubItem: UIView! + @IBOutlet fileprivate weak var subItemIcon: UIImageView! + @IBOutlet fileprivate weak var subItemTitle: UILabel! + @IBOutlet fileprivate weak var subItemHeight: NSLayoutConstraint! + @IBOutlet fileprivate weak var titleCenterY: NSLayoutConstraint! + + @IBOutlet fileprivate weak var itemLabel: UILabel! @IBOutlet fileprivate weak var currentBarView: UIView! @IBOutlet fileprivate weak var currentBarViewHeightConstraint: NSLayoutConstraint! @@ -47,7 +87,7 @@ class TabCollectionCell: UICollectionViewCell { } override func sizeThatFits(_ size: CGSize) -> CGSize { - if item.characters.count == 0 { + if item.count == 0 { return CGSize.zero } @@ -85,12 +125,12 @@ extension TabCollectionCell { func highlightTitle() { itemLabel.textColor = option.currentColor - itemLabel.font = UIFont.boldSystemFont(ofSize: option.fontSize) + //itemLabel.font = UIFont.boldSystemFont(ofSize: option.fontSize) } func unHighlightTitle() { itemLabel.textColor = option.defaultColor - itemLabel.font = UIFont.systemFont(ofSize: option.fontSize) + //itemLabel.font = UIFont.systemFont(ofSize: option.fontSize) } } diff --git a/Sources/TabCollectionCell.xib b/Sources/TabCollectionCell.xib old mode 100644 new mode 100755 index b7c69bd..2a70bed --- a/Sources/TabCollectionCell.xib +++ b/Sources/TabCollectionCell.xib @@ -1,17 +1,23 @@ - + - + + + + + Effra-Regular + + - + @@ -19,12 +25,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +