diff --git a/FlatButton.xcodeproj/project.pbxproj b/FlatButton.xcodeproj/project.pbxproj
index 781d2bb..081ba03 100644
--- a/FlatButton.xcodeproj/project.pbxproj
+++ b/FlatButton.xcodeproj/project.pbxproj
@@ -249,7 +249,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@@ -275,7 +275,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.FlatButton;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@@ -328,6 +328,7 @@
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -370,6 +371,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -383,7 +385,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.FlatButton-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -397,7 +399,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "org.cindori.FlatButton-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/FlatButton.xcodeproj/project.xcworkspace/xcuserdata/zeo.xcuserdatad/UserInterfaceState.xcuserstate b/FlatButton.xcodeproj/project.xcworkspace/xcuserdata/zeo.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..0856bd2
Binary files /dev/null and b/FlatButton.xcodeproj/project.xcworkspace/xcuserdata/zeo.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/FlatButton.xcodeproj/xcshareddata/xcschemes/FlatButton.xcscheme b/FlatButton.xcodeproj/xcshareddata/xcschemes/FlatButton.xcscheme
index 3ad1f4f..bb5edf1 100644
--- a/FlatButton.xcodeproj/xcshareddata/xcschemes/FlatButton.xcscheme
+++ b/FlatButton.xcodeproj/xcshareddata/xcschemes/FlatButton.xcscheme
@@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
@@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/FlatButton.xcodeproj/xcuserdata/zeo.xcuserdatad/xcschemes/xcschememanagement.plist b/FlatButton.xcodeproj/xcuserdata/zeo.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..eacd4fe
--- /dev/null
+++ b/FlatButton.xcodeproj/xcuserdata/zeo.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,19 @@
+
+
+
+
+ SchemeUserState
+
+ FlatButton-Example.xcscheme
+
+ orderHint
+ 1
+
+ FlatButton.xcscheme_^#shared#^_
+
+ orderHint
+ 0
+
+
+
+
diff --git a/FlatButton/FlatButton.swift b/FlatButton/FlatButton.swift
index 97f904d..09542f8 100644
--- a/FlatButton/FlatButton.swift
+++ b/FlatButton/FlatButton.swift
@@ -28,7 +28,7 @@ internal extension CALayer {
internal extension NSColor {
internal func tintedColor() -> NSColor {
var h = CGFloat(), s = CGFloat(), b = CGFloat(), a = CGFloat()
- let rgbColor = usingColorSpaceName(NSCalibratedRGBColorSpace)
+ let rgbColor = usingColorSpaceName(NSColorSpaceName.calibratedRGB)
rgbColor?.getHue(&h, saturation: &s, brightness: &b, alpha: &a)
return NSColor(hue: h, saturation: s, brightness: b == 0 ? 0.2 : b * 0.8, alpha: a)
}
@@ -43,7 +43,7 @@ open class FlatButton: NSButton, CALayerDelegate {
internal var mouseDown = Bool()
@IBInspectable public var momentary: Bool = true {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var onAnimationDuration: Double = 0
@@ -51,13 +51,13 @@ open class FlatButton: NSButton, CALayerDelegate {
@IBInspectable public var glowRadius: CGFloat = 0 {
didSet {
containerLayer.shadowRadius = glowRadius
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var glowOpacity: Float = 0 {
didSet {
containerLayer.shadowOpacity = glowOpacity
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var cornerRadius: CGFloat = 4 {
@@ -72,42 +72,42 @@ open class FlatButton: NSButton, CALayerDelegate {
}
@IBInspectable public var borderColor: NSColor = NSColor.darkGray {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var activeBorderColor: NSColor = NSColor.white {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var buttonColor: NSColor = NSColor.darkGray {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var activeButtonColor: NSColor = NSColor.white {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var iconColor: NSColor = NSColor.gray {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var activeIconColor: NSColor = NSColor.black {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var textColor: NSColor = NSColor.gray {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@IBInspectable public var activeTextColor: NSColor = NSColor.gray {
didSet {
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@@ -194,7 +194,7 @@ open class FlatButton: NSButton, CALayerDelegate {
}
func positionTitleAndImage() {
- let attributes = [NSFontAttributeName: font as Any]
+ let attributes = [NSAttributedStringKey.font: font as Any]
let titleSize = title.size(withAttributes: attributes)
var titleRect = NSMakeRect(0, 0, titleSize.width, titleSize.height)
var imageRect = iconLayer.frame
@@ -315,10 +315,11 @@ open class FlatButton: NSButton, CALayerDelegate {
// MARK: Interaction
public func setOn(_ isOn: Bool) {
- let nextState = isOn ? NSOnState : NSOffState
+// let nextState = isOn ? .on : .off
+ let nextState = isOn ? NSControl.StateValue.on : NSControl.StateValue.off
if nextState != state {
state = nextState
- animateColor(state == NSOnState)
+ animateColor(state == .on)
}
}
@@ -329,19 +330,19 @@ open class FlatButton: NSButton, CALayerDelegate {
override open func mouseDown(with event: NSEvent) {
if isEnabled {
mouseDown = true
- setOn(state == NSOnState ? false : true)
+ setOn(state == .on ? false : true)
}
}
override open func mouseEntered(with event: NSEvent) {
if mouseDown {
- setOn(state == NSOnState ? false : true)
+ setOn(state == .on ? false : true)
}
}
override open func mouseExited(with event: NSEvent) {
if mouseDown {
- setOn(state == NSOnState ? false : true)
+ setOn(state == .on ? false : true)
mouseDown = false
}
}
@@ -350,7 +351,7 @@ open class FlatButton: NSButton, CALayerDelegate {
if mouseDown {
mouseDown = false
if momentary {
- setOn(state == NSOnState ? false : true)
+ setOn(state == .on ? false : true)
}
_ = target?.perform(action, with: self)
}
@@ -386,3 +387,4 @@ open class FlatButton: NSButton, CALayerDelegate {
}
+