Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e199eed4d | |||
| 4b50636ab8 | |||
| 4cef47a199 |
+1
-1
@@ -1,7 +1,7 @@
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = 'OGSwitch'
|
||||
s.version = '1.3'
|
||||
s.version = '1.5'
|
||||
s.summary = 'Switch with icon'
|
||||
s.homepage = 'https://github.com/OskarGroth/OGSwitch'
|
||||
s.license = {
|
||||
|
||||
+3
-3
@@ -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">
|
||||
<Locations>
|
||||
|
||||
+38
-8
@@ -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
|
||||
@@ -257,12 +285,14 @@ public class OGSwitch : NSControl {
|
||||
}
|
||||
|
||||
if isOn != on {
|
||||
isOn = on
|
||||
if action != nil {
|
||||
NSApp.sendAction(action!, to: target, from: self)
|
||||
}
|
||||
} else {
|
||||
isOn = on
|
||||
}
|
||||
|
||||
isOn = on
|
||||
|
||||
hasDragged = false
|
||||
isDraggingTowardsOn = false
|
||||
|
||||
@@ -13,6 +13,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@IBOutlet weak var window: NSWindow!
|
||||
|
||||
@IBOutlet weak var switchButton: OGSwitch!
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Insert code here to initialize your application
|
||||
@@ -22,6 +23,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
// Insert code here to tear down your application
|
||||
}
|
||||
|
||||
@IBAction func switchPress(_ sender: Any) {
|
||||
print("Trim is now: \(switchButton.isOn)")
|
||||
perform(#selector(timer), with: nil, afterDelay: 3)
|
||||
}
|
||||
|
||||
@objc func timer() {
|
||||
print("Trim is after now: \(switchButton.isOn)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12118"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -15,6 +15,7 @@
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="OGSwitchDemo" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="switchButton" destination="M7z-uc-a7v" id="s1F-OI-IzO"/>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
@@ -696,7 +697,13 @@
|
||||
<userDefinedRuntimeAttribute type="image" keyPath="inactiveIcon" value="NSEnterFullScreenTemplate"/>
|
||||
<userDefinedRuntimeAttribute type="image" keyPath="activeIcon" value="NSBookmarksTemplate"/>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="ignoreRatio" value="YES"/>
|
||||
<userDefinedRuntimeAttribute type="color" keyPath="disabledBackgroundColor">
|
||||
<color key="value" red="1" green="0.40000000600000002" blue="0.40000000600000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="switchPress:" target="Voe-Tx-rLC" id="Mqi-G6-fmv"/>
|
||||
</connections>
|
||||
</customView>
|
||||
</subviews>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user