Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be0bd0211b | |||
| 3f6129964e | |||
| 352f7c8ad2 | |||
| 52781c2335 | |||
| 6adaab83d6 |
BIN
Binary file not shown.
@@ -11,7 +11,7 @@ import QuartzCore
|
||||
|
||||
//Can not be NSControl due to 10.9 issues: https://github.com/iluuu1994/ITSwitch/issues/21
|
||||
|
||||
@IBDesignable public class OGSwitch : NSView {
|
||||
@IBDesignable public class OGSwitch: NSControl {
|
||||
|
||||
@IBInspectable public var tintColor: NSColor = NSColor(calibratedRed:0.27, green: 0.86, blue: 0.36, alpha: 1.0) {
|
||||
didSet {
|
||||
@@ -54,7 +54,7 @@ import QuartzCore
|
||||
reloadLayer()
|
||||
}
|
||||
}
|
||||
@IBInspectable public var isEnabled: Bool = true {
|
||||
override public var isEnabled: Bool {
|
||||
didSet {
|
||||
reloadLayerAnimated(animated: true)
|
||||
}
|
||||
@@ -66,8 +66,6 @@ import QuartzCore
|
||||
let kEnabledOpacity:Float = 1.0
|
||||
let kDisabledOpacity:Float = 0.5
|
||||
var dragEvents = 0
|
||||
@objc public var action: Selector?
|
||||
@objc public var target: AnyObject?
|
||||
public var isOn:Bool = false
|
||||
public var isActive:Bool = false
|
||||
public var hasDragged:Bool = false
|
||||
|
||||
@@ -24,7 +24,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
@IBAction func switchPress(_ sender: Any) {
|
||||
NSLog("Switch is now: \(switchButton.isOn)")
|
||||
NSLog("Switch is now: \((sender as! OGSwitch).isOn)")
|
||||
// perform(#selector(timer), with: nil, afterDelay: 3)
|
||||
}
|
||||
|
||||
|
||||
@@ -681,7 +681,7 @@
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<window title="OGSwitch-DemoDemo" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<window title="OGSwitch-Demo" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
@@ -696,9 +696,8 @@
|
||||
<userDefinedRuntimeAttributes>
|
||||
<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"/>
|
||||
<color key="value" name="systemGreenColor" catalog="System" colorSpace="catalog"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="isEnabled" value="YES"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="switchPress:" target="Voe-Tx-rLC" id="Mqi-G6-fmv"/>
|
||||
@@ -721,7 +720,7 @@
|
||||
</customView>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="86" y="-105"/>
|
||||
<point key="canvasLocation" x="198" y="-127"/>
|
||||
</window>
|
||||
</objects>
|
||||
<resources>
|
||||
|
||||
@@ -11,7 +11,7 @@ This is a `NSView` subclass that lets you create beautiful iOS-inspired switches
|
||||
|
||||
`OGSwitch` now also supports `IBDesignable` and renders directly in Interface Builder:
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Installation (Carthage)
|
||||
@@ -19,6 +19,8 @@ Configure your Cartfile to use `OGSwitch`:
|
||||
|
||||
```github "OskarGroth/OGSwitch" ~> 2.0```
|
||||
|
||||
`OGSwitch` requires Swift 4.2.
|
||||
|
||||
## Usage
|
||||
|
||||
Create a custom `NSView` in Interface Builder and set it's class to `OGSwitch`.
|
||||
@@ -35,7 +37,7 @@ Inspired by ITSwitch by Ilija Tovilo.
|
||||
## License
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Oskar Groth
|
||||
Copyright (c) 2018 Oskar Groth
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
Reference in New Issue
Block a user