UISwitch for Mac OS X

https://github.com/iluuu1994/ITSwitch
ITSwitch is a replica of UISwitch for Mac OS X

ITSwitch is a simple and lightweight replica of iOS 7 UISwitch for Mac OS X.

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:

[switch bind:@"checked" toObject:self withKeyPath:@"prop" options:nil];

Use these two properties to explicitely mutate the switches state:

/**
 *  @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:

height = 20;
width = height * 1.618;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值