-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathViewCell.m
More file actions
68 lines (57 loc) · 1.83 KB
/
Copy pathViewCell.m
File metadata and controls
68 lines (57 loc) · 1.83 KB
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
65
66
67
68
//
// ViewCell.m
// TTableViewExample
//
// Created by ren pan on 13-9-7.
// Copyright (c) 2013年 ren pan. All rights reserved.
//
#import "ViewCell.h"
@interface ViewCell ()
{
UILabel* label_title;
UIButton* buttonRight;
}
@end
@implementation ViewCell
@synthesize blockCellDelete = _blockCellDelete;
- (void)initForSubClass
{
self.enableLeft = NO;
self.enableRight = YES;
self.leftNewOffsetX = 80;
self.rightNewOffsetX = self.contentView.frame.size.width + 80;
if(label_title == nil)
{
label_title = [[UILabel alloc] initWithFrame:self.bounds];
[label_title setBackgroundColor:[UIColor clearColor]];
[self.contentView addSubview:label_title];
}
}
- (void)layoutBottomView
{
if(!self.bottomRightView)
{
self.bottomRightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
self.bottomRightView.backgroundColor = [UIColor redColor];
[self insertSubview:self.bottomRightView atIndex:0];
CGRect f = self.bottomRightView.frame;
buttonRight = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonRight setTitle:@"删除" forState:UIControlStateNormal];
buttonRight.frame = CGRectMake(f.size.width - 80, 0, 80, f.size.height);
[buttonRight setTitleColor:[UIColor colorWithWhite:1.0 alpha:0.5] forState:UIControlStateHighlighted];
[self.bottomRightView addSubview:buttonRight];
[buttonRight addTarget:self action:@selector(btnDelete:) forControlEvents:UIControlEventTouchUpInside];
}
}
- (void)setData:(id)data
{
label_title.text = [NSString stringWithFormat:@"section = %d, row = %d", self.indexPath.section, self.indexPath.row];
}
- (void)btnDelete:(id)sender
{
if(_blockCellDelete)
{
_blockCellDelete(self);
}
}
@end