Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CBFlashyTabBarController/Classes/CBFlashyTabBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ open class CBFlashyTabBar: UITabBar {

}
}

open var font = UIFont.systemFont(ofSize: 12, weight: .semibold) {
didSet {
reloadViews()
}
}

open override var tintColor: UIColor! {
didSet {
Expand Down Expand Up @@ -95,6 +101,7 @@ open class CBFlashyTabBar: UITabBar {
private func button(forItem item: UITabBarItem) -> CBTabBarButton {
let button = CBTabBarButton(item: item)
button.tintColor = tintColor
button.font = font
button.addTarget(self, action: #selector(btnPressed), for: .touchUpInside)
if selectedItem != nil && item === selectedItem {
button.select(animated: false)
Expand Down
11 changes: 11 additions & 0 deletions CBFlashyTabBarController/Classes/CBFlashyTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import UIKit
open class CBFlashyTabBarController: UITabBarController {

fileprivate var shouldSelectOnTabBar = true

open var font = UIFont.systemFont(ofSize: 12, weight: .semibold) {
didSet {
(tabBar as? CBFlashyTabBar)?.font = font
}
}

open override var selectedViewController: UIViewController? {
willSet {
Expand Down Expand Up @@ -41,10 +47,15 @@ open class CBFlashyTabBarController: UITabBarController {

open override func viewDidLoad() {
super.viewDidLoad()
setupTabbar()
}

func setupTabbar() {
guard self.tabBar as? CBFlashyTabBar == nil else {
return
}
let tabBar = CBFlashyTabBar()
tabBar.font = font
if let barTint = self.tabBar.barTintColor {
tabBar.barTintColor = barTint
}
Expand Down
11 changes: 9 additions & 2 deletions CBFlashyTabBarController/Classes/CBTabBarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class CBTabBarButton: UIControl {
}
}

var font = UIFont.systemFont(ofSize: 12, weight: .semibold) {
didSet {
tabLabel.attributedText = attributedText(fortitle: item?.title)
tabLabel.font = font
}
}

override init(frame: CGRect) {
super.init(frame: frame)
configureSubviews()
Expand Down Expand Up @@ -70,7 +77,7 @@ class CBTabBarButton: UIControl {
var attrs: [NSAttributedString.Key: Any] = [:]
attrs[.kern] = -0.2
attrs[.foregroundColor] = tintColor
attrs[.font] = UIFont.systemFont(ofSize: 12, weight: .semibold)
attrs[.font] = font
return NSAttributedString(string: title ?? "", attributes: attrs)
}

Expand All @@ -79,7 +86,7 @@ class CBTabBarButton: UIControl {
addSubview(tabImage)
addSubview(dotView)
tabLabel.numberOfLines = 2
tabLabel.font = UIFont.systemFont(ofSize: 12, weight: .semibold)
tabLabel.font = font
tabLabel.isHidden = true
tabImage.contentMode = .center
let dotSize: CGFloat = 5.0
Expand Down