7
7
//
8
8
9
9
#define kTaskCommentCell_FontContent [UIFont systemFontOfSize: 15 ]
10
- #define kTaskCommentCell_LeftPading 30.0
11
- #define kTaskCommentCell_LeftContentPading (kTaskCommentCell_LeftPading + 40 )
12
- #define kTaskCommentCell_ContentWidth (kScreen_Width - kTaskCommentCell_LeftContentPading - kTaskCommentCell_LeftPading )
10
+ #define kTaskCommentCell_LeftContentPading (30 + 15 * 2 + 15 )
11
+ #define kTaskCommentCell_ContentWidth (kScreen_Width - kTaskCommentCell_LeftContentPading - 15 * 2 )
13
12
14
13
#import " TaskCommentCell.h"
15
14
#import " UICustomCollectionView.h"
@@ -34,7 +33,6 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
34
33
if (self) {
35
34
// Initialization code
36
35
self.selectionStyle = UITableViewCellSelectionStyleNone;
37
- CGFloat curBottomY = 25 ;
38
36
if (!_contentBGView) {
39
37
_contentBGView = [UIImageView new ];
40
38
_contentBGView.image = [[UIImage imageNamed: @" comment_bg" ] resizableImageWithCapInsets: UIEdgeInsetsMake (35 , 15 , 5 , 5 )];
@@ -49,23 +47,22 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
49
47
if (!_ownerIconView) {
50
48
CGFloat borderWidth = 2 ;
51
49
52
- UIView *bgView = [[UIView alloc ] initWithFrame: CGRectMake (kPaddingLeftWidth - borderWidth, curBottomY, 28 + 2 *borderWidth, 28 + 2 *borderWidth)];
50
+ UIView *bgView = [[UIView alloc ] initWithFrame: CGRectMake (kPaddingLeftWidth - borderWidth, 12 , 33 + 2 *borderWidth, 33 + 2 *borderWidth)];
53
51
bgView.backgroundColor = kColorTableBG ;
54
52
55
- _ownerIconView = [[UIImageView alloc ] initWithFrame: CGRectMake (0 , 0 , 28 , 28 )];
53
+ _ownerIconView = [[UIImageView alloc ] initWithFrame: CGRectMake (0 , 0 , 33 , 33 )];
56
54
_ownerIconView.layer .masksToBounds = YES ;
57
55
_ownerIconView.layer .cornerRadius = _ownerIconView.frame .size .width /2 ;
58
56
59
57
[bgView addSubview: _ownerIconView];
60
58
[_ownerIconView mas_makeConstraints: ^(MASConstraintMaker *make) {
61
- make.width .height .mas_equalTo (28 .0 );
59
+ make.width .height .mas_equalTo (33 .0 );
62
60
make.center .equalTo (bgView);
63
61
}];
64
-
65
62
[self .contentView addSubview: bgView];
66
63
}
67
64
if (!_contentLabel) {
68
- _contentLabel = [[UITTTAttributedLabel alloc ] initWithFrame: CGRectMake (kTaskCommentCell_LeftContentPading , curBottomY , kTaskCommentCell_ContentWidth , 30 )];
65
+ _contentLabel = [[UITTTAttributedLabel alloc ] initWithFrame: CGRectMake (kTaskCommentCell_LeftContentPading , 7 + 15 , kTaskCommentCell_ContentWidth , 30 )];
69
66
_contentLabel.textColor = kColor222 ;
70
67
_contentLabel.font = kTaskCommentCell_FontContent ;
71
68
_contentLabel.linkAttributes = kLinkAttributes ;
@@ -93,7 +90,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
93
90
}
94
91
}
95
92
[_contentBGView mas_makeConstraints: ^(MASConstraintMaker *make) {
96
- make.edges .equalTo (self.contentView ).insets (UIEdgeInsetsMake (10 , 60 - 7 , 10 , 20 ));
93
+ make.edges .equalTo (self.contentView ).insets (UIEdgeInsetsMake (7 , 33 + 15 * 2 - 9 , 7 , 15 ));
97
94
}];
98
95
if (!_detailBtn) {
99
96
_detailBtn = [UIButton buttonWithTitle: @" 查看详情" titleColor: kColorBrandGreen ];
@@ -122,7 +119,6 @@ - (void)setCurComment:(TaskComment *)curComment{
122
119
return ;
123
120
}
124
121
_detailBtn.hidden = ![self .curComment.htmlMedia needToShowDetail ];
125
- CGFloat curBottomY = 25 ;
126
122
[_ownerIconView sd_setImageWithURL: [_curComment.owner.avatar urlImageWithCodePathResizeToView: _ownerIconView] placeholderImage: kPlaceholderMonkeyRoundWidth (33.0 )];
127
123
128
124
NSString *contentStr = _curComment.content ;
@@ -134,19 +130,19 @@ - (void)setCurComment:(TaskComment *)curComment{
134
130
}
135
131
}
136
132
137
- curBottomY += [contentStr getHeightWithFont: kTaskCommentCell_FontContent constrainedToSize: CGSizeMake (kTaskCommentCell_ContentWidth , CGFLOAT_MAX)] + 5 ;
133
+ CGFloat curBottomY = CGRectGetMinY (_contentLabel. frame ) + [contentStr getHeightWithFont: kTaskCommentCell_FontContent constrainedToSize: CGSizeMake (kTaskCommentCell_ContentWidth , CGFLOAT_MAX)];
138
134
139
135
NSInteger imagesCount = _curComment.htmlMedia .imageItems .count ;
140
136
if (imagesCount > 0 ) {
137
+ curBottomY += 5 ;
141
138
self.imageCollectionView .hidden = NO ;
142
139
[self .imageCollectionView setFrame: CGRectMake (kTaskCommentCell_LeftContentPading , curBottomY, kTaskCommentCell_ContentWidth , [TaskCommentCell imageCollectionViewHeightWithCount: imagesCount])];
143
140
[self .imageCollectionView reloadData ];
141
+ curBottomY += [TaskCommentCell imageCollectionViewHeightWithCount: imagesCount];
144
142
}else {
143
+ curBottomY += 10 ;
145
144
self.imageCollectionView .hidden = YES ;
146
145
}
147
-
148
- curBottomY += [TaskCommentCell imageCollectionViewHeightWithCount: imagesCount];
149
-
150
146
[_timeLabel setY: curBottomY];
151
147
_timeLabel.width = _detailBtn.hidden ? kTaskCommentCell_ContentWidth : kTaskCommentCell_ContentWidth - 60 ;
152
148
_timeLabel.text = [NSString stringWithFormat: @" %@ 发布于 %@ " , _curComment.owner.name, [_curComment.created_at stringDisplay_HHmm ]];
@@ -172,9 +168,17 @@ + (CGFloat)cellHeightWithObj:(id)obj{
172
168
|| [obj isKindOfClass: [FileComment class ]]) {
173
169
TaskComment *curComment = (TaskComment *)obj;
174
170
NSString *contentStr = curComment.content ;
175
- cellHeight += 20 +[contentStr getHeightWithFont: kTaskCommentCell_FontContent constrainedToSize: CGSizeMake (kTaskCommentCell_ContentWidth , CGFLOAT_MAX)] + 5 +20 +10 ;
176
- cellHeight += [self imageCollectionViewHeightWithCount: curComment.htmlMedia.imageItems.count];
171
+ cellHeight += 7 + 15 +[contentStr getHeightWithFont: kTaskCommentCell_FontContent constrainedToSize: CGSizeMake (kTaskCommentCell_ContentWidth , CGFLOAT_MAX)];
172
+ if (curComment.htmlMedia .imageItems .count > 0 ) {
173
+ cellHeight += 5 + [self imageCollectionViewHeightWithCount: curComment.htmlMedia.imageItems.count];
174
+ }else {
175
+ cellHeight += 10 ;
176
+ }
177
177
cellHeight += 20 ;
178
+ cellHeight += 15 + 7 ;
179
+ // + 5 +20 +10;
180
+ // cellHeight += [self imageCollectionViewHeightWithCount:curComment.htmlMedia.imageItems.count];
181
+ // cellHeight += 20;
178
182
}
179
183
return cellHeight;
180
184
}
0 commit comments