diff --git a/FlatButton.xcodeproj/project.xcworkspace/xcuserdata/Oskar.xcuserdatad/UserInterfaceState.xcuserstate b/FlatButton.xcodeproj/project.xcworkspace/xcuserdata/Oskar.xcuserdatad/UserInterfaceState.xcuserstate index f24aebb..2385899 100644 Binary files a/FlatButton.xcodeproj/project.xcworkspace/xcuserdata/Oskar.xcuserdatad/UserInterfaceState.xcuserstate and b/FlatButton.xcodeproj/project.xcworkspace/xcuserdata/Oskar.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/FlatButton/FlatButton.swift b/FlatButton/FlatButton.swift index c253ffb..30d462a 100644 --- a/FlatButton/FlatButton.swift +++ b/FlatButton/FlatButton.swift @@ -193,7 +193,14 @@ public class FlatButton: NSButton, CALayerDelegate { let borderColor = bgColor layer?.animate(color: bgColor.cgColor, keyPath: "backgroundColor", duration: duration) layer?.animate(color: borderColor.cgColor, keyPath: "borderColor", duration: duration) - titleLayer.animate(color: titleColor.cgColor, keyPath: "foregroundColor", duration: duration) + + /* I started seeing high (~5%) background CPU usage in apps using + FlatButton, and was able to track it down to background CATextLayer animation calls + happening constantly, originating from the call below. It could be a CATextLayer bug. + For now I'm going with setting the color instantly as it fixes this issue. */ + //titleLayer.animate(color: titleColor.cgColor, keyPath: "foregroundColor", duration: duration) + titleLayer.foregroundColor = titleColor.cgColor + iconLayer.animate(color: imageColor.cgColor, keyPath: "backgroundColor", duration: duration) }