文档

单选框控件

更新时间:

本文主要展示单选框控件效果和提供其代码示例。

  • AUCheckBox 为单选框控件 。

  • AUCheckBox 迁移自 APCommonUI 的 APCheckbox。请使用 AUCheckBox。

效果图

AUCheckBox

接口说明

/**
 checkbox 类型

 - AUCheckBoxStyleDefault:   默认样式,与 web 的 checkbox 类似
 - AUCheckBoxStyleCheckmark: tableview 的 checkmark 样式
 */
typedef NS_ENUM(NSInteger, AUCheckBoxStyle) {
        AUCheckBoxStyleDefault,
        AUCheckBoxStyleCheckmark
};


/**
 单选框控件
 */
@interface AUCheckBox : UIControl

/**
 根据类型初始化 AUCheckBox 方法

 @param style checkbox 类型

 @return AUCheckBox
 */
- (instancetype)initWithStyle:(AUCheckBoxStyle)style;

/**
 是否选中属性
 */
@property(nonatomic, assign, getter = isChecked) BOOL checked;

/**
 是否 disabled 属性
 */
@property(nonatomic, assign, getter = isDisabled) BOOL disabled;

/**
 checkbox 类型(只读,只能在初始化时设置)
 */
@property (nonatomic, assign, readonly) AUCheckBoxStyle style;


@end

代码示例

AUCheckBox *checkbox = [[AUCheckBox alloc] initWithStyle:AUCheckBoxStyleDefault];
checkbox.checked = YES;
checkbox.disabled = NO;
checkbox.origin = CGPointMake(100, 250);
[checkbox addTarget:self action:@selector(checkboxValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:checkbox];

- (void)checkboxValueChanged:(id)sender
{
        AUCheckBox *checkbox = (AUCheckBox *)sender;
        NSLog(@"%@", checkbox);
}
  • 本页导读 (0)
文档反馈