Skip to content

Commit

Permalink
SetOn
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarGroth committed Apr 10, 2017
1 parent 2e199ee commit 0523e25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "77"
endingLineNumber = "77"
landmarkName = "setupIcon()"
landmarkName = "init(coder:)"
landmarkType = "7">
<Locations>
<Location
Expand Down
7 changes: 7 additions & 0 deletions OGSwitch/OGSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public class OGSwitch : NSControl {
setupIcon()
}

public func setOn(isOn: Bool, animated: Bool) {
if self.isOn != isOn {
self.isOn = isOn
reloadLayerAnimated(animated: animated)
}
}

internal func setupIcon() {
guard let icon = inactiveIcon, let bounds = knobLayer?.bounds else {
return
Expand Down
1 change: 1 addition & 0 deletions OGSwitchDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

@objc func timer() {
print("Trim is after now: \(switchButton.isOn)")
switchButton.setOn(isOn: !switchButton.isOn, animated: false)
}

}
Expand Down

0 comments on commit 0523e25

Please sign in to comment.