Closed marcusleon closed 7 years ago
Seems to be fixed by following the approach at http://stackoverflow.com/a/40319706/47281
Specifically adding .withRenderingMode(UIImageRenderingMode.alwaysOriginal)
to the UIImage constructors and then adding the setTitleTextAttributes
calls.
Updated FAIcon.swift:
public extension UITabBarItem {
public func setFAIcon(icon: FAType, size: CGSize? = nil, textColor: UIColor = UIColor.black, backgroundColor: UIColor = UIColor.clear, selectedTextColor: UIColor = UIColor.black, selectedBackgroundColor: UIColor = UIColor.clear) {
FontLoader.loadFontIfNeeded()
let tabBarItemImageSize = size ?? CGSize(width: 30, height: 30)
image = UIImage(icon: icon, size: tabBarItemImageSize, textColor: textColor, backgroundColor: backgroundColor).withRenderingMode(UIImageRenderingMode.alwaysOriginal)
selectedImage = UIImage(icon: icon, size: tabBarItemImageSize, textColor: selectedTextColor, backgroundColor: selectedBackgroundColor).withRenderingMode(UIImageRenderingMode.alwaysOriginal)
setTitleTextAttributes([NSForegroundColorAttributeName: textColor], for: .normal)
setTitleTextAttributes([NSForegroundColorAttributeName: selectedTextColor], for: .selected)
}
}
Is this a candidate change to be added to the lib?
thanks for your contribution
This works fine:
The tab icon FABell icon appears.
But the image and text color is blue even though the defaults to the setFAIcon method are black.
Passing a value for the selected selectedTextColor and other color properties do not seem to have any affect on the color.
How can you change the color? Are we doing something incorrectly?
Thanks