Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for setting the border when the switch is on #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions SevenSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down