Commit 8611b3c7 by M. Porooshani

refs #860 adds better handling of TabBar items' colors

parent af62cb93
......@@ -131,6 +131,14 @@ open class Button: UIButton, Pulseable, PulseableLayer {
setTitleColor(titleColor, for: .highlighted)
}
}
/// Sets the selected titleColor for the button.
@IBInspectable
open var selectedTitleColor: UIColor? {
didSet {
setTitleColor(selectedTitleColor, for: .selected)
}
}
/**
An initializer that initializes the object with a NSCoder object.
......
......@@ -139,7 +139,14 @@ open class TabBar: Bar {
internal weak var _delegate: _TabBarDelegate?
/// The currently selected tabItem.
open internal(set) var selectedTabItem: TabItem?
open internal(set) var selectedTabItem: TabItem? {
willSet {
selectedTabItem?.isSelected = false
}
didSet {
selectedTabItem?.isSelected = true
}
}
/// A preset wrapper around tabItems contentEdgeInsets.
open var tabItemsContentEdgeInsetsPreset: EdgeInsetsPreset {
......@@ -194,7 +201,20 @@ open class TabBar: Bar {
layoutSubviews()
}
}
/// Tab bars normal title color.
open var tabItemsNormalTitleColor: UIColor? {
didSet {
}
}
open var tabItemsSelectedTitleColor: UIColor? {
didSet {
}
}
/// A reference to the line UIView.
open let line = UIView()
......@@ -272,7 +292,9 @@ fileprivate extension TabBar {
for v in tabItems {
v.grid.columns = 0
v.contentEdgeInsets = .zero
if Color.blue.base == v.titleColor { v.titleColor = tabItemsNormalTitleColor }
if nil == v.selectedTitleColor { v.selectedTitleColor = tabItemsSelectedTitleColor }
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