From 46d92940fb9d3d0a29a76e967c0b87d7e1dc9669 Mon Sep 17 00:00:00 2001 From: Leaf Chen Date: Fri, 26 May 2017 15:58:19 +0800 Subject: [PATCH] Support for setting the border when the switch is on --- SevenSwitch.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/SevenSwitch.swift b/SevenSwitch.swift index d504345..bdeefcf 100644 --- a/SevenSwitch.swift +++ b/SevenSwitch.swift @@ -79,6 +79,17 @@ import QuartzCore } } + /* + * Sets the border color that shows when the switch is on. Defaults to clear. + */ + @IBInspectable open var onBorderColor: UIColor = UIColor.clear { + willSet { + if self.on { + backgroundView.layer.borderColor = newValue.cgColor + } + } + } + /* * Sets the border color that shows when the switch is off. Defaults to light gray. */ @@ -444,7 +455,7 @@ import QuartzCore } self.backgroundView.backgroundColor = self.onTintColor - self.backgroundView.layer.borderColor = self.onTintColor.cgColor + self.backgroundView.layer.borderColor = self.onBorderColor.cgColor self.thumbView.backgroundColor = self.onThumbTintColor self.onImageView.alpha = 1.0 self.offImageView.alpha = 0 @@ -470,7 +481,7 @@ import QuartzCore } backgroundView.backgroundColor = self.onTintColor - backgroundView.layer.borderColor = self.onTintColor.cgColor + backgroundView.layer.borderColor = self.onBorderColor.cgColor thumbView.backgroundColor = self.onThumbTintColor onImageView.alpha = 1.0 offImageView.alpha = 0