IOS开发(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-15 19:49 点击:次
label.textAlignment = UITextAlignmentLeft;
[self addSubview:label];
[self addTarget:self action:@selector(clicked) forControlEvents: UIControlEventTouchUpInside];
}
return self;
}
-(BOOL)isChecked {
return checked;
}
-(void)setChecked: (BOOL)flag {
if (flag != checked)
{
checked = flag;
}
if (checked)
{
[icon setImage: [UIImage imageNamed:@"checkBoxSelect.png"]];
}
else
{
[icon setImage: [UIImage imageNamed:@"checkBoxNoSelect.png"]];
}
}
-(void)clicked {
[self setChecked: !checked];
if (delegate != nil)
{
SEL sel = NSSelectorFromString (@"checkButtonClicked");
if ([delegate respondsToSelector: sel])
{
[delegate performSelector: sel];
}
}
}
-(void)dealloc {
delegate = nil;
[label release];
[icon release];
[super dealloc];
}
@end
使用方法:
[html] www.2cto.com
UICheckBoxButton *checkBoxButton = [[ UICheckBoxButton alloc] initWithFrame: CGRectMake(30, 50, 220, 25)];
checkBoxButton.delegate = self.delegate;
checkBoxButton.label.text = [Common getTextByTag:@"noCostPrompt"];
相关新闻>>
- 发表评论
-
- 最新评论 更多>>