From 61c0a1ba98b76bf6400114f5a5b80e33473eca68 Mon Sep 17 00:00:00 2001 From: Todd Kirby Date: Fri, 1 Apr 2022 12:41:19 +0700 Subject: [PATCH 1/2] Allow to specify image rendering mode in IconSegment. Added iconRenderingMode parameter to IconSegment constructor to allow using rendering modes other than template. Parameter defaults to current behavior. --- Pod/Classes/Segments/IconSegment.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/Segments/IconSegment.swift b/Pod/Classes/Segments/IconSegment.swift index 01286db..ec4330e 100644 --- a/Pod/Classes/Segments/IconSegment.swift +++ b/Pod/Classes/Segments/IconSegment.swift @@ -32,8 +32,9 @@ open class IconSegment: BetterSegmentedControlSegment { normalBackgroundColor: UIColor? = nil, normalIconTintColor: UIColor, selectedBackgroundColor: UIColor? = nil, - selectedIconTintColor: UIColor) { - self.icon = icon.withRenderingMode(.alwaysTemplate) + selectedIconTintColor: UIColor, + iconRenderingMode: UIImage.RenderingMode = .alwaysTemplate) { + self.icon = icon.withRenderingMode(iconRenderingMode) self.iconSize = iconSize self.normalBackgroundColor = normalBackgroundColor ?? DefaultValues.normalBackgroundColor self.normalIconTintColor = normalIconTintColor From c4689d20462cc470af332c50316077249bb79249 Mon Sep 17 00:00:00 2001 From: Todd Kirby Date: Fri, 1 Apr 2022 12:41:19 +0700 Subject: [PATCH 2/2] Allow to specify image rendering mode in IconSegment. Added iconRenderingMode parameter to IconSegment constructor to allow using rendering modes other than template. Parameter defaults to current behavior. --- Pod/Classes/Segments/IconSegment.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Pod/Classes/Segments/IconSegment.swift b/Pod/Classes/Segments/IconSegment.swift index 01286db..cb2a3b9 100644 --- a/Pod/Classes/Segments/IconSegment.swift +++ b/Pod/Classes/Segments/IconSegment.swift @@ -32,8 +32,9 @@ open class IconSegment: BetterSegmentedControlSegment { normalBackgroundColor: UIColor? = nil, normalIconTintColor: UIColor, selectedBackgroundColor: UIColor? = nil, - selectedIconTintColor: UIColor) { - self.icon = icon.withRenderingMode(.alwaysTemplate) + selectedIconTintColor: UIColor, + iconRenderingMode: UIImage.RenderingMode = .alwaysTemplate) { + self.icon = icon.withRenderingMode(iconRenderingMode) self.iconSize = iconSize self.normalBackgroundColor = normalBackgroundColor ?? DefaultValues.normalBackgroundColor self.normalIconTintColor = normalIconTintColor @@ -84,14 +85,16 @@ public extension IconSegment { normalBackgroundColor: UIColor? = nil, normalIconTintColor: UIColor, selectedBackgroundColor: UIColor? = nil, - selectedIconTintColor: UIColor) -> [BetterSegmentedControlSegment] { + selectedIconTintColor: UIColor, + iconRenderingMode: UIImage.RenderingMode = .alwaysTemplate) -> [BetterSegmentedControlSegment] { return icons.map { IconSegment(icon: $0, iconSize: iconSize, normalBackgroundColor: normalBackgroundColor, normalIconTintColor: normalIconTintColor, selectedBackgroundColor: selectedBackgroundColor, - selectedIconTintColor: selectedIconTintColor) + selectedIconTintColor: selectedIconTintColor, + iconRenderingMode: iconRenderingMode) } } }