Skip to content

Commit be6994e

Browse files
committed
冒泡详情 - 调整
1 parent 7f6c8b8 commit be6994e

File tree

4 files changed

+59
-39
lines changed

4 files changed

+59
-39
lines changed

Coding_iOS/Controllers/TweetDetailViewController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
279279
cell.commentToCommentBlock = ^(Comment *toComment, id sender){
280280
[self doCommentToComment:toComment sender:sender];
281281
};
282-
[cell.ownerIconView addTapBlock:^(id obj) {
283-
[self goToUserInfo:curComment.owner];
284-
}];
282+
// [cell.ownerIconView addTapBlock:^(id obj) {
283+
// [self goToUserInfo:curComment.owner];
284+
// }];
285285
cell.contentLabel.delegate = self;
286286
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
287287
return cell;

Coding_iOS/Views/Cell/TweetDetailCell.m

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#define kTweetDetailCell_LikeComment_Height 27.0
1212
#define kTweetDetailCell_LikeComment_Width 50.0
1313
#define kTweetDetailCell_ContentWidth (kScreen_Width - 2*kPaddingLeftWidth)
14-
#define kTweetDetailCell_PadingTop 55.0
14+
#define kTweetDetailCell_PadingTop 70.0
1515
#define kTweetDetailCell_PadingBottom 10.0
1616
#define kTweetDetailCell_LikeUserCCell_Height 25.0
17-
#define kTweetDetailCell_LikeUserCCell_Pading 10.0
17+
#define kTweetDetailCell_LikeUserCCell_Pading 5.0
1818

19-
#define kTweetDetailCell_MaxCollectionNum (kDevice_Is_iPhone6Plus? 12: kDevice_Is_iPhone6? 11: 9)
19+
#define kTweetDetailCell_MaxCollectionNum (kDevice_Is_iPhone6Plus? 11: kDevice_Is_iPhone6? 10: 9)
2020

2121

2222

@@ -54,13 +54,13 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
5454
self.selectionStyle = UITableViewCellSelectionStyleNone;
5555
// self.backgroundColor = [UIColor colorWithHexString:@"0xf3f3f3"];
5656
if (!self.ownerImgView) {
57-
self.ownerImgView = [[UITapImageView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 10, 38, 38)];
57+
self.ownerImgView = [[UITapImageView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 10, 45, 45)];
5858
[self.ownerImgView doCircleFrame];
5959
[self.contentView addSubview:self.ownerImgView];
6060
}
6161
if (!self.ownerNameBtn) {
6262
self.ownerNameBtn = [UIButton buttonWithUserStyle];
63-
self.ownerNameBtn.frame = CGRectMake(kTweetDetailCell_PadingLeft, CGRectGetMinY(self.ownerImgView.frame), kScreen_Width/2, 20);
63+
self.ownerNameBtn.frame = CGRectMake(CGRectGetMaxX(_ownerImgView.frame) + 15, CGRectGetMinY(self.ownerImgView.frame), kScreen_Width/2, 24);
6464
[self.ownerNameBtn addTarget:self action:@selector(userBtnClicked) forControlEvents:UIControlEventTouchUpInside];
6565
[self.contentView addSubview:self.ownerNameBtn];
6666
}
@@ -70,11 +70,11 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
7070
// [self.contentView addSubview:self.timeClockIconView];
7171
// }
7272
if (!self.timeLabel) {
73-
self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.ownerNameBtn.frame), CGRectGetMaxY(self.ownerImgView.frame) - 12, kScreen_Width/2, 12)];
73+
self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.ownerNameBtn.frame), CGRectGetMaxY(self.ownerImgView.frame) - 17, kScreen_Width/2, 17)];
7474
// self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreen_Width - kPaddingLeftWidth - 70, 18, 70, 12)];
7575
self.timeLabel.font = kTweet_TimtFont;
7676
// self.timeLabel.textAlignment = NSTextAlignmentRight;
77-
self.timeLabel.textColor = kColor999;
77+
self.timeLabel.textColor = kColorDark7;
7878
[self.contentView addSubview:self.timeLabel];
7979
}
8080

@@ -128,7 +128,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
128128
if (!self.fromLabel) {
129129
self.fromLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.fromPhoneIconView.frame) + 5, 0, kScreen_Width/2, 15)];
130130
self.fromLabel.font = kTweet_TimtFont;
131-
self.fromLabel.textColor = kColor999;
131+
self.fromLabel.textColor = kColorDark7;
132132
[self.contentView addSubview:self.fromLabel];
133133
}
134134
if (!self.likeUsersView) {
@@ -291,7 +291,7 @@ + (CGFloat)likeCommentBtn_BottomPadingWithTweet:(Tweet *)tweet{
291291
+ (CGFloat)likeUsersHeightWithTweet:(Tweet *)tweet{
292292
CGFloat likeUsersHeight = 0;
293293
if ([tweet hasLikesOrRewards]) {
294-
likeUsersHeight = 35;
294+
likeUsersHeight = [TweetLikeUserCCell ccellSize].height + 15 + 5;
295295
// +30*(ceilf([tweet.like_users count]/kTweet_LikeUsersLineCount)-1);
296296
}
297297
return likeUsersHeight;
@@ -435,14 +435,12 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
435435
return ccell;
436436
}
437437
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
438-
CGSize itemSize;
439-
itemSize = CGSizeMake(kTweetDetailCell_LikeUserCCell_Height, kTweetDetailCell_LikeUserCCell_Height);
438+
CGSize itemSize = [TweetLikeUserCCell ccellSize];
440439
return itemSize;
441440
}
442441
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
443442
UIEdgeInsets insetForSection;
444-
445-
insetForSection = UIEdgeInsetsMake(kTweetDetailCell_LikeUserCCell_Pading, kPaddingLeftWidth, kTweetDetailCell_LikeUserCCell_Pading, kPaddingLeftWidth);
443+
insetForSection = UIEdgeInsetsMake(15, kPaddingLeftWidth, 5, kPaddingLeftWidth);
446444
return insetForSection;
447445
}
448446
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{

Coding_iOS/Views/Cell/TweetDetailCommentCell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@property (strong, nonatomic) Comment *toComment;
1818
@property (nonatomic, copy) void (^commentToCommentBlock)(Comment *, id);
1919
@property (strong, nonatomic) UITTTAttributedLabel *contentLabel;
20-
@property (strong, nonatomic) UITapImageView *ownerIconView;
20+
//@property (strong, nonatomic) UITapImageView *ownerIconView;
2121

2222
+ (CGFloat)cellHeightWithObj:(id)obj;
2323

Coding_iOS/Views/Cell/TweetDetailCommentCell.m

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
#import "Login.h"
1313

1414
@interface TweetDetailCommentCell ()
15-
@property (strong, nonatomic) UILabel *timeLabel;
15+
//@property (strong, nonatomic) UILabel *timeLabel;
16+
17+
@property (strong, nonatomic) UILabel *userNameLabel, *timeLabel;
18+
@property (strong, nonatomic) UIImageView *timeClockIconView;
19+
1620
@end
1721

1822
@implementation TweetDetailCommentCell
@@ -22,29 +26,35 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
2226
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
2327
if (self) {
2428
// Initialization code
25-
CGFloat curBottomY = 10;
26-
if (!_ownerIconView) {
27-
_ownerIconView = [[UITapImageView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, curBottomY, 33, 33)];
28-
[_ownerIconView doCircleFrame];
29-
[self.contentView addSubview:_ownerIconView];
30-
}
31-
CGFloat curWidth = kScreen_Width - 40 - 2*kPaddingLeftWidth;
3229
if (!_contentLabel) {
33-
_contentLabel = [[UITTTAttributedLabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth + 40, curBottomY, curWidth, 30)];
30+
_contentLabel = [[UITTTAttributedLabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 15, kScreen_Width - 2*kPaddingLeftWidth, 30)];
3431
_contentLabel.numberOfLines = 0;
35-
_contentLabel.textColor = kColor222;
32+
_contentLabel.textColor = kColorDark4;
3633
_contentLabel.font = kTweetDetailCommentCell_FontContent;
3734
_contentLabel.linkAttributes = kLinkAttributes;
3835
_contentLabel.activeLinkAttributes = kLinkAttributesActive;
3936
[self.contentView addSubview:_contentLabel];
4037
}
41-
CGFloat commentBtnWidth = 40;
38+
if (!_userNameLabel) {
39+
_userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 0, 150, 15)];
40+
_userNameLabel.backgroundColor = [UIColor clearColor];
41+
_userNameLabel.font = [UIFont boldSystemFontOfSize:12];
42+
_userNameLabel.textColor = kColorDark7;
43+
[self.contentView addSubview:_userNameLabel];
44+
}
4245
if (!_timeLabel) {
43-
_timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth +40, 0, curWidth- commentBtnWidth, 20)];
44-
_timeLabel.textColor = kColor999;
46+
_timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(75, 0, 80, 15)];
47+
_timeLabel.backgroundColor = [UIColor clearColor];
4548
_timeLabel.font = [UIFont systemFontOfSize:12];
49+
_timeLabel.textColor = kColorDark7;
4650
[self.contentView addSubview:_timeLabel];
4751
}
52+
if (!_timeClockIconView) {
53+
_timeClockIconView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 0, 15, 15)];
54+
_timeClockIconView.contentMode = UIViewContentModeCenter;
55+
_timeClockIconView.image = [UIImage imageNamed:@"time_clock_icon"];
56+
[self.contentView addSubview:_timeClockIconView];
57+
}
4858
}
4959
return self;
5060
}
@@ -62,10 +72,8 @@ - (void)layoutSubviews{
6272
if (!_toComment) {
6373
return;
6474
}
65-
CGFloat curBottomY = 10;
66-
CGFloat curWidth = kScreen_Width - 40 - 2*kPaddingLeftWidth;
67-
[_ownerIconView sd_setImageWithURL:[_toComment.owner.avatar urlImageWithCodePathResizeToView:_ownerIconView] placeholderImage:kPlaceholderMonkeyRoundView(_ownerIconView)];
68-
75+
CGFloat curBottomY = 15;
76+
CGFloat curWidth = kScreen_Width - 2*kPaddingLeftWidth;
6977
[_contentLabel setWidth:curWidth];
7078
_contentLabel.text = _toComment.content;
7179
[_contentLabel sizeToFit];
@@ -76,9 +84,23 @@ - (void)layoutSubviews{
7684
}
7785
}
7886

79-
curBottomY += [_toComment.content getHeightWithFont:kTweetDetailCommentCell_FontContent constrainedToSize:CGSizeMake(curWidth, CGFLOAT_MAX)] + 5;
80-
[_timeLabel setY:curBottomY];
81-
_timeLabel.text = [NSString stringWithFormat:@"%@ 发布于 %@", _toComment.owner.name, [_toComment.created_at stringDisplay_HHmm]];
87+
curBottomY += [_toComment.content getHeightWithFont:kTweetDetailCommentCell_FontContent constrainedToSize:CGSizeMake(curWidth, CGFLOAT_MAX)] + 10;
88+
89+
90+
_userNameLabel.text = _toComment.owner.name;
91+
_timeLabel.text = [_toComment.created_at stringDisplay_HHmm];
92+
[_userNameLabel setY:curBottomY];
93+
[_userNameLabel sizeToFit];
94+
95+
CGRect frame = _timeClockIconView.frame;
96+
frame.origin.y = curBottomY;
97+
frame.origin.x = 10 + CGRectGetMaxX(_userNameLabel.frame);
98+
_timeClockIconView.frame = frame;
99+
100+
frame.origin.x += 5 + CGRectGetWidth(_timeClockIconView.frame);
101+
frame.size = _timeLabel.frame.size;
102+
_timeLabel.frame = frame;
103+
[_timeLabel sizeToFit];
82104
}
83105

84106
- (void)commentBtnClicked:(id)sender{
@@ -92,8 +114,8 @@ + (CGFloat)cellHeightWithObj:(id)obj{
92114
CGFloat cellHeight = 0;
93115
if ([obj isKindOfClass:[Comment class]]) {
94116
Comment *toComment = (Comment *)obj;
95-
CGFloat curWidth = kScreen_Width - 40 - 2*kPaddingLeftWidth;
96-
cellHeight += 10 +[toComment.content getHeightWithFont:kTweetDetailCommentCell_FontContent constrainedToSize:CGSizeMake(curWidth, CGFLOAT_MAX)] + 5 +20 +10;
117+
CGFloat curWidth = kScreen_Width - 2*kPaddingLeftWidth;
118+
cellHeight += 15 +[toComment.content getHeightWithFont:kTweetDetailCommentCell_FontContent constrainedToSize:CGSizeMake(curWidth, CGFLOAT_MAX)] + 10 +15 +15;
97119
}
98120
return cellHeight;
99121
}

0 commit comments

Comments
 (0)