From 2e199eed4d085069745217147b79b1119da52acd Mon Sep 17 00:00:00 2001 From: Oskar Groth Date: Sat, 8 Apr 2017 14:22:18 +0200 Subject: [PATCH] Initial coloring, IBVar reloads --- OGSwitch.podspec | 2 +- .../xcdebugger/Breakpoints_v2.xcbkptlist | 6 +-- OGSwitch/OGSwitch.swift | 42 +++++++++++++++---- OGSwitchDemo/Base.lproj/MainMenu.xib | 3 ++ 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/OGSwitch.podspec b/OGSwitch.podspec index 1712e80..a34e5eb 100644 --- a/OGSwitch.podspec +++ b/OGSwitch.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'OGSwitch' -s.version = '1.4' +s.version = '1.5' s.summary = 'Switch with icon' s.homepage = 'https://github.com/OskarGroth/OGSwitch' s.license = { diff --git a/OGSwitch.xcodeproj/xcuserdata/oskar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/OGSwitch.xcodeproj/xcuserdata/oskar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 333f3c7..cd097df 100644 --- a/OGSwitch.xcodeproj/xcuserdata/oskar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/OGSwitch.xcodeproj/xcuserdata/oskar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,11 +10,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "OGSwitch/OGSwitch.swift" - timestampString = "509792812.217359" + timestampString = "513346877.889494" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "69" - endingLineNumber = "69" + startingLineNumber = "77" + endingLineNumber = "77" landmarkName = "setupIcon()" landmarkType = "7"> diff --git a/OGSwitch/OGSwitch.swift b/OGSwitch/OGSwitch.swift index d86db4b..e600157 100644 --- a/OGSwitch/OGSwitch.swift +++ b/OGSwitch/OGSwitch.swift @@ -11,14 +11,42 @@ import QuartzCore public class OGSwitch : NSControl { - @IBInspectable public var tintColor: NSColor = NSColor(calibratedRed:0.27, green: 0.86, blue: 0.36, alpha: 1.0) - @IBInspectable public var knobBackgroundColor: NSColor = NSColor(calibratedWhite:1.0, alpha: 1.0) - @IBInspectable public var disabledBorderColor: NSColor = NSColor(calibratedWhite: 0.0, alpha: 0.2) - @IBInspectable public var disabledBackgroundColor: NSColor = NSColor.clear - @IBInspectable public var inactiveBackgroundColor: NSColor = NSColor(calibratedWhite: 0.0, alpha:0.3) + @IBInspectable public var tintColor: NSColor = NSColor(calibratedRed:0.27, green: 0.86, blue: 0.36, alpha: 1.0) { + didSet { + reloadLayer() + } + } + @IBInspectable public var knobBackgroundColor: NSColor = NSColor(calibratedWhite:1.0, alpha: 1.0) { + didSet { + reloadLayer() + } + } + @IBInspectable public var disabledBorderColor: NSColor = NSColor(calibratedWhite: 0.0, alpha: 0.2) { + didSet { + reloadLayer() + } + } + @IBInspectable public var disabledBackgroundColor: NSColor = NSColor.clear { + didSet { + reloadLayer() + } + } + @IBInspectable public var inactiveBackgroundColor: NSColor = NSColor(calibratedWhite: 0.0, alpha:0.3) { + didSet { + reloadLayer() + } + } @IBInspectable public var animationDuration: TimeInterval = 0.4 - @IBInspectable public var inactiveIcon: NSImage? - @IBInspectable public var activeIcon: NSImage? + @IBInspectable public var inactiveIcon: NSImage? { + didSet { + reloadLayer() + } + } + @IBInspectable public var activeIcon: NSImage? { + didSet { + reloadLayer() + } + } @IBInspectable public var ignoreRatio: Bool = false let kBorderLineWidth:CGFloat = 1.0 diff --git a/OGSwitchDemo/Base.lproj/MainMenu.xib b/OGSwitchDemo/Base.lproj/MainMenu.xib index c42a57d..44fa9d0 100644 --- a/OGSwitchDemo/Base.lproj/MainMenu.xib +++ b/OGSwitchDemo/Base.lproj/MainMenu.xib @@ -697,6 +697,9 @@ + + +