The button can also be edited in Interface Builder, but Xcode is very buggy with @IBDesignable, so I would recommend using it only programmatically for now.
FAQ
Can you support Carthage and CocoaPods?
No, but you can still use Swift Package Manager for this package even though you mainly use Carthage or CocoaPods.
Won’t SwiftUI make this moot?
SwiftUI does indeed make it much easier to create custom-looking buttons, but SwiftUI is still immature and most companies will not be able to require macOS 10.15 for a long time. So this package will still be useful for multiple years to come.
CustomButton
It’s a layer-based NSButton subclass that animates the styles and colors between normal and active (pressed) state.
This package is used in production by Gifski.
Requirements
Install
Add
https://github.com/sindresorhus/CustomButton
in the “Swift Package Manager” tab in Xcode.Usage
See the source for what properties you can change and play with it in the example app. By default, it has no style.
The button can also be edited in Interface Builder, but Xcode is very buggy with
@IBDesignable
, so I would recommend using it only programmatically for now.FAQ
Can you support Carthage and CocoaPods?
No, but you can still use Swift Package Manager for this package even though you mainly use Carthage or CocoaPods.
Won’t SwiftUI make this moot?
SwiftUI does indeed make it much easier to create custom-looking buttons, but SwiftUI is still immature and most companies will not be able to require macOS 10.15 for a long time. So this package will still be useful for multiple years to come.
Related
You might also like my apps.