From ed2a69711308c323d34238c2fab1608738a76137 Mon Sep 17 00:00:00 2001 From: Ryan Zulkoski Date: Thu, 5 Nov 2015 07:48:32 -0600 Subject: [PATCH 1/4] Disabled setBackgroundColor to mimic an actual UIStackView and added '.DS_Store' to .gitignore. --- .gitignore | 1 + TZStackView/TZStackView.swift | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 8615121..624ccbf 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ DerivedData *.hmap *.ipa *.xcuserstate +.DS_Store # CocoaPods # diff --git a/TZStackView/TZStackView.swift b/TZStackView/TZStackView.swift index 2fd77a8..4d17023 100755 --- a/TZStackView/TZStackView.swift +++ b/TZStackView/TZStackView.swift @@ -56,6 +56,17 @@ public class TZStackView: UIView { private var registeredKvoSubviews = [UIView]() private var animatingToHiddenViews = [UIView]() + + private var _backgroundColor: UIColor? = nil + override public var backgroundColor: UIColor? { + get { + return self._backgroundColor + } + set { + // Disable setBackgroundColor to mimic a real UIStackView which is a non-drawing view. + self._backgroundColor = nil + } + } public init(arrangedSubviews: [UIView] = []) { super.init(frame: CGRectZero) From 599d371d219368ea1c47418500d3cdfe23d1faf3 Mon Sep 17 00:00:00 2001 From: Ryan Zulkoski Date: Thu, 5 Nov 2015 09:31:11 -0600 Subject: [PATCH 2/4] Simplified backgroundColor override. --- TZStackView/TZStackView.swift | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/TZStackView/TZStackView.swift b/TZStackView/TZStackView.swift index 4d17023..5aeb8d4 100755 --- a/TZStackView/TZStackView.swift +++ b/TZStackView/TZStackView.swift @@ -57,15 +57,10 @@ public class TZStackView: UIView { private var animatingToHiddenViews = [UIView]() - private var _backgroundColor: UIColor? = nil + // Disable setBackgroundColor to mimic an actual UIStackView which is a non-drawing view. override public var backgroundColor: UIColor? { - get { - return self._backgroundColor - } - set { - // Disable setBackgroundColor to mimic a real UIStackView which is a non-drawing view. - self._backgroundColor = nil - } + get { return nil } + set { } } public init(arrangedSubviews: [UIView] = []) { From c74900b656c1c51ebc7b79c8f5f058510129db38 Mon Sep 17 00:00:00 2001 From: Ryan Zulkoski Date: Thu, 5 Nov 2015 09:55:20 -0600 Subject: [PATCH 3/4] Made backgroundColor override a one-liner. --- TZStackView/TZStackView.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/TZStackView/TZStackView.swift b/TZStackView/TZStackView.swift index 5aeb8d4..77fb06c 100755 --- a/TZStackView/TZStackView.swift +++ b/TZStackView/TZStackView.swift @@ -58,10 +58,7 @@ public class TZStackView: UIView { private var animatingToHiddenViews = [UIView]() // Disable setBackgroundColor to mimic an actual UIStackView which is a non-drawing view. - override public var backgroundColor: UIColor? { - get { return nil } - set { } - } + override public var backgroundColor: UIColor? { get { return nil } set { } } public init(arrangedSubviews: [UIView] = []) { super.init(frame: CGRectZero) From 20a0dab5655006f625cfa5f0d37972631ccb90d8 Mon Sep 17 00:00:00 2001 From: Ryan Zulkoski Date: Fri, 6 Nov 2015 07:55:34 -0600 Subject: [PATCH 4/4] Added an override for the class method layerClass rather than overriding backgroundColor property to disable setting the backgroundColor as suggested by @CosynPa --- TZStackView/TZStackView.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TZStackView/TZStackView.swift b/TZStackView/TZStackView.swift index 77fb06c..dd577c7 100755 --- a/TZStackView/TZStackView.swift +++ b/TZStackView/TZStackView.swift @@ -56,9 +56,6 @@ public class TZStackView: UIView { private var registeredKvoSubviews = [UIView]() private var animatingToHiddenViews = [UIView]() - - // Disable setBackgroundColor to mimic an actual UIStackView which is a non-drawing view. - override public var backgroundColor: UIColor? { get { return nil } set { } } public init(arrangedSubviews: [UIView] = []) { super.init(frame: CGRectZero) @@ -608,4 +605,9 @@ public class TZStackView: UIView { } return animatingToHiddenViews.indexOf(view) != nil } + + // Disables setting the background color to mimic an actual UIStackView which is a non-drawing view. + override public class func layerClass() -> AnyClass { + return CATransformLayer.self + } }