-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDHCheckBox.m
64 lines (47 loc) · 1.28 KB
/
DHCheckBox.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// DHCheckBox.m
// SmartITOM
//
// Created by Apple002 on 12-10-25.
// Copyright (c) 2012年 Apple002. All rights reserved.
//
#import "DHCheckBox.h"
@implementation DHCheckBox
//@synthesize num;
@synthesize delegate;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
delegate = nil;
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[self setImage:[UIImage imageNamed:@"com_btn_check.png"] forState:UIControlStateNormal];
[self addTarget:self action:@selector(checkBoxClicked) forControlEvents:UIControlEventTouchUpInside];
self.selected = FALSE;
}
return self;
}
- (void)setTarget:(id)_target action:(SEL)action andTag:(NSInteger)_num
{
self.tag = _num;
target = _target;
fun = action;
}
-(void) checkBoxClicked
{
NSLog(@"DHCheckBox:checkBoxClicked");
self.selected = !self.selected;
if (self.selected) {
[self setImage:[UIImage imageNamed:@"com_btn_checked.png"] forState:UIControlStateNormal];
}
else
{
[self setImage:[UIImage imageNamed:@"com_btn_check.png"] forState:UIControlStateNormal];
}
if (nil != delegate)
{
[delegate didRequestCheckBox:self.selected andTag:self.tag];
}
}
@end