14

I’m sure most of you are familiar with the UISwitch on iOS.

Is their any existing project trying to implement something like a UISwitch for macOS and AppKit?

If not, where would one start to make one? I see them frequently and can think of so many uses.

pkamb
  • 33,281
  • 23
  • 160
  • 191
nosedive25
  • 2,477
  • 5
  • 30
  • 45

7 Answers7

15

I think you should use NSCheckBox since it is the equivalent on a computer where you use a mouse and not your finger.

Simon
  • 31,675
  • 9
  • 80
  • 92
7

For anyone that comes across this question in the future, I have developed a UISwitch for Mac (MacToggle) Swift 3 & AutoLayout

https://github.com/RichAppz/MacToggle

enter image description here

It's a replica of the iOS UISwitch and fully customisable.

Enjoy

RichAppz
  • 1,520
  • 2
  • 14
  • 27
6

I've used the Mondo Switch that's part of the Cocoa Mondo Kit. It works pretty well.

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
6

I recently extended Peter Hosey's PRHOnOffButton to add iOS-like background colors and labels. Since mine is derived, it may or may not have the same caveat described above by Peter.

enter image description here

DK_
  • 2,648
  • 2
  • 21
  • 20
  • It's been quite a while since I needed a switch. After the upgrade to Xcode 4 and having Mondo Switch no longer work, I wrote an view based switch as part of my personal framework. – nosedive25 Feb 06 '12 at 01:00
5

You could use Peter Hosey’s PRHOnOffButton.

Community
  • 1
  • 1
  • Caveat: There are some bugs in the public source that I have fixed locally, but haven't pushed the fixes for yet. Those who want a real UISwitch-like control should follow PRHOnOffButton on Bitbucket (or subscribe to its feed) in order to be notified when I make those fixes final and public. – Peter Hosey Jan 27 '11 at 04:57
3

ITSwitch requires no images, integrates with Interface Builder and has lovely (modern) animations:

https://github.com/iluuu1994/ITSwitch

Recommended.

mxcl
  • 26,392
  • 12
  • 99
  • 98
3

starting with macOS 10.15 'Catalina' there is a native control for that called NSSwitch: https://developer.apple.com/documentation/appkit/nsswitch?language=objc

user1259710
  • 868
  • 2
  • 9
  • 12
  • Unfortunately we need our apps to work on older versions of macOS like El Capitan or Mojave. So the NSSwitch wont work on those OS's – KamyFC Feb 05 '21 at 10:00