要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install
。
#import <MECheckbox/MECheckbox.h>
...
// by code
UIImage *checked = [UIImage imageNamed:@"checked"];
UIImage *unchecked = [UIImage imageNamed:@"unchecked"];
CGRect frame = CGRectMake(0, 0, checked.size.width, checked.size.height);
MECheckbox *checkbox = [[MECheckbox alloc] initWithFrame:frame];
checkbox.checkedImage = checked;
checkbox.uncheckedImage = unchecked;
[self.view addSubview:checkbox];
或者只需使用 Interface Builder - 将 UIView 拖动到上,将它设置为 MECheckbox 类,然后使用可设计属性 'checked' 和 'unchecked' - IB 会实时在任何视图上绘制 checkbox(在 storyboard 或 xib 中)。
您可以使用任何您想要的 UIImage,但请记住 - 勾选框不会自动调整大小以适应新图像。您必须手动设置勾选框的 frame 或通过 Auto Layout 完成!
UIKit
MECheckbox 可以通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中:
pod "MECheckbox"
SoundBlaster,[email protected]
MECheckbox 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。