Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a4e1d06b19 | |||
| 79209bca05 | |||
| 2004091f18 |
BIN
Binary file not shown.
@@ -13,6 +13,25 @@ import QuartzCore
|
||||
|
||||
@IBDesignable public class OGSwitch: NSControl {
|
||||
|
||||
public enum Size {
|
||||
|
||||
case small
|
||||
case medium
|
||||
case large
|
||||
|
||||
public var size: CGSize {
|
||||
switch self {
|
||||
case .small:
|
||||
return CGSize(width: 46, height: 28)
|
||||
case .medium:
|
||||
return CGSize(width: 56, height: 34)
|
||||
case .large:
|
||||
return CGSize(width: 69, height: 41)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@IBInspectable public var tintColor: NSColor = NSColor(calibratedRed:0.27, green: 0.86, blue: 0.36, alpha: 1.0) {
|
||||
didSet {
|
||||
reloadLayer()
|
||||
@@ -60,7 +79,8 @@ import QuartzCore
|
||||
}
|
||||
}
|
||||
|
||||
let kBorderLineWidth:CGFloat = 1.0
|
||||
lazy var kBorderLineWidth: CGFloat = bounds.height*(2/31)
|
||||
|
||||
let kGoldenRatio:CGFloat = 1.6180339875
|
||||
let kDecreasedGoldenRatio:CGFloat = 1.38
|
||||
let kEnabledOpacity:Float = 1.0
|
||||
@@ -88,11 +108,15 @@ import QuartzCore
|
||||
setup()
|
||||
}
|
||||
|
||||
override init(frame:NSRect) {
|
||||
convenience public init(size: CGSize) {
|
||||
self.init(frame: NSRect(origin: .zero, size: size))
|
||||
}
|
||||
|
||||
override public init(frame:NSRect) {
|
||||
super.init(frame: frame);
|
||||
setup()
|
||||
}
|
||||
|
||||
|
||||
override public func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
reloadLayerSize()
|
||||
@@ -151,9 +175,9 @@ import QuartzCore
|
||||
knobLayer!.autoresizingMask = CAAutoresizingMask.layerHeightSizable
|
||||
knobLayer!.backgroundColor = knobBackgroundColor.cgColor
|
||||
knobLayer!.shadowColor = NSColor.black.cgColor
|
||||
knobLayer!.shadowOffset = CGSize(width:0.0, height:-2.0)
|
||||
knobLayer!.shadowRadius = 1.0
|
||||
knobLayer!.shadowOpacity = 0.3
|
||||
knobLayer!.shadowOffset = CGSize(width:0.0, height:-6.5)
|
||||
knobLayer!.shadowRadius = 2.5
|
||||
knobLayer!.shadowOpacity = 0.15
|
||||
knobLayer?.masksToBounds = false
|
||||
rootLayer!.addSublayer(knobLayer!)
|
||||
|
||||
|
||||
@@ -704,26 +704,47 @@
|
||||
</connections>
|
||||
</customView>
|
||||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Brb-kf-Oxi" customClass="OGSwitch" customModule="OGSwitch">
|
||||
<rect key="frame" x="159" y="63" width="163" height="96"/>
|
||||
<rect key="frame" x="140" y="60" width="46" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="image" keyPath="activeIcon" value="checkmark"/>
|
||||
<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>
|
||||
<userDefinedRuntimeAttribute type="image" keyPath="inactiveIcon" value="checkmark"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="switchPress:" target="Voe-Tx-rLC" id="tTg-hX-q3I"/>
|
||||
</connections>
|
||||
</customView>
|
||||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dPq-0j-nKi" customClass="OGSwitch" customModule="OGSwitch">
|
||||
<rect key="frame" x="272" y="53" width="69" height="41"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<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"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="switchPress:" target="Voe-Tx-rLC" id="buu-wq-UpG"/>
|
||||
</connections>
|
||||
</customView>
|
||||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1VD-pu-2Ej" customClass="OGSwitch" customModule="OGSwitch">
|
||||
<rect key="frame" x="200" y="57" width="56" height="34"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<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"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="switchPress:" target="Voe-Tx-rLC" id="wRK-Gm-efR"/>
|
||||
</connections>
|
||||
</customView>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="198" y="-127"/>
|
||||
</window>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="checkmark" width="35" height="34"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
Reference in New Issue
Block a user