Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iluuu1994/itswitch
ITSwitch is a replica of UISwitch for Mac OS X
https://github.com/iluuu1994/itswitch
objective-c uiswitch
Last synced: about 22 hours ago
JSON representation
ITSwitch is a replica of UISwitch for Mac OS X
- Host: GitHub
- URL: https://github.com/iluuu1994/itswitch
- Owner: iluuu1994
- License: apache-2.0
- Created: 2014-02-01T10:45:12.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-04-01T10:42:47.000Z (almost 7 years ago)
- Last Synced: 2025-01-14T19:34:45.228Z (8 days ago)
- Topics: objective-c, uiswitch
- Language: Objective-C
- Homepage:
- Size: 1.16 MB
- Stars: 289
- Watchers: 11
- Forks: 42
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ITSwitch
========`ITSwitch` is a simple and lightweight replica of iOS 7 `UISwitch` for Mac OS X.
![](./demo.png)
Usage
-----Not much to it, simply set the custom class of a `NSView` to `ITSwitch` in Interface Builder.
You can create an IBAction and simply connect the two in Interface Builder.
Or you can use Cocoa Bindings to directly bind it to one of your properties:```objc
[switch bind:@"checked" toObject:self withKeyPath:@"prop" options:nil];
```Use these two properties to explicitely mutate the switches state:
```objc
/**
* @property checked - Gets or sets the switches state
*/
@property (nonatomic, assign) IBInspectable BOOL checked;/**
* @property tintColor - Gets or sets the switches tint
*/
@property (nonatomic, strong) IBInspectable NSColor *tintColor;
```Since `ITSwitch` uses its `CALayer` to draw a drop-shadow, you should also layer-back it's superview.
If you don't use Core Animation, you can also simply embed the view in a layer-backed view.Requirements
------------ITSwitch requires 10.9+ and linking against the QuartzCore.framework.
Tips
----You may want to consider setting the width of the view to the golden ratio * height.
So for example:
```objc
height = 20;
width = height * 1.618;
```