Commit 1595584f by M. Porooshani

Provided default values for when user set's nil as color for tab bar items

parent 14a9756e
...@@ -203,10 +203,24 @@ open class TabBar: Bar { ...@@ -203,10 +203,24 @@ open class TabBar: Bar {
} }
/// TabBar items normal title color. /// TabBar items normal title color.
open var tabItemsNormalTitleColor: UIColor? open var tabItemsNormalTitleColor: UIColor? {
didSet {
let normalColor = tabItemsNormalTitleColor ?? Color.blue.base
for v in tabItems {
if (nil == v.titleColor || Color.blue.base == v.titleColor) { v.titleColor = normalColor }
}
}
}
/// TabBar items selected title color. /// TabBar items selected title color.
open var tabItemsSelectedTitleColor: UIColor? open var tabItemsSelectedTitleColor: UIColor? {
didSet {
let selectedColor = tabItemsSelectedTitleColor ?? Color.blue.base
for v in tabItems {
if (nil == v.selectedTitleColor || Color.blue.base == v.selectedTitleColor) { v.selectedTitleColor = selectedColor }
}
}
}
/// A reference to the line UIView. /// A reference to the line UIView.
open let line = UIView() open let line = UIView()
...@@ -285,8 +299,10 @@ fileprivate extension TabBar { ...@@ -285,8 +299,10 @@ fileprivate extension TabBar {
for v in tabItems { for v in tabItems {
v.grid.columns = 0 v.grid.columns = 0
v.contentEdgeInsets = .zero v.contentEdgeInsets = .zero
if Color.blue.base == v.titleColor { v.titleColor = tabItemsNormalTitleColor } let normalColor = tabItemsNormalTitleColor ?? Color.blue.base
if nil == v.selectedTitleColor { v.selectedTitleColor = tabItemsSelectedTitleColor } if Color.blue.base == v.titleColor { v.titleColor = normalColor }
let selectedColor = tabItemsSelectedTitleColor ?? Color.blue.base
if nil == v.selectedTitleColor { v.selectedTitleColor = selectedColor }
prepareLineAnimationHandler(tabItem: v) prepareLineAnimationHandler(tabItem: v)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment