From df154a8d44530804ad62fa1445c30f3237216dd9 Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 29 Aug 2019 16:52:35 +0200 Subject: [PATCH] added support to image tintcolor when image are always templated --- Segmentio/Source/Cells/SegmentioCell.swift | 1 + Segmentio/Source/SegmentioOptions.swift | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Segmentio/Source/Cells/SegmentioCell.swift b/Segmentio/Source/Cells/SegmentioCell.swift index 43d0cd0..d859ec1 100644 --- a/Segmentio/Source/Cells/SegmentioCell.swift +++ b/Segmentio/Source/Cells/SegmentioCell.swift @@ -148,6 +148,7 @@ class SegmentioCell: UICollectionViewCell { if (style != .onlyLabel) { segmentImageView?.image = selected ? selectedImage : image + segmentImageView?.tintColor = selected ? selectedState.imageTintColor : defaultState.imageTintColor } } diff --git a/Segmentio/Source/SegmentioOptions.swift b/Segmentio/Source/SegmentioOptions.swift index c711ede..57b7c12 100644 --- a/Segmentio/Source/SegmentioOptions.swift +++ b/Segmentio/Source/SegmentioOptions.swift @@ -50,15 +50,18 @@ public struct SegmentioState { var titleFont: UIFont var titleTextColor: UIColor var titleAlpha: CGFloat + var imageTintColor: UIColor public init( backgroundColor: UIColor = .clear, titleFont: UIFont = UIFont.systemFont(ofSize: UIFont.smallSystemFontSize), titleTextColor: UIColor = .black, + imageTintColor: UIColor? = nil, titleAlpha: CGFloat = 1) { self.backgroundColor = backgroundColor self.titleFont = titleFont self.titleTextColor = titleTextColor + self.imageTintColor = imageTintColor ?? titleTextColor self.titleAlpha = titleAlpha }