Commit 543012fd by Daniel Dahan Committed by GitHub

Merge pull request #908 from mohpor/development

Provided default values for when user set's nil as color for tab bar items.
parents 14a9756e 20768a11
...@@ -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()
...@@ -281,12 +295,13 @@ fileprivate extension TabBar { ...@@ -281,12 +295,13 @@ fileprivate extension TabBar {
/// Prepares the tabItems. /// Prepares the tabItems.
func prepareTabItems() { func prepareTabItems() {
shouldNotAnimateLineView = true shouldNotAnimateLineView = true
let normalColor = tabItemsNormalTitleColor ?? Color.blue.base
let selectedColor = tabItemsSelectedTitleColor ?? Color.blue.base
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 } if Color.blue.base == v.titleColor { v.titleColor = normalColor }
if nil == v.selectedTitleColor { v.selectedTitleColor = tabItemsSelectedTitleColor } 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