Skip to content

Commit 5cd71fd

Browse files
committed
讨论UI调整
1 parent 1c08427 commit 5cd71fd

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

Coding_iOS/Views/Cell/TopicContentCell.m

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,17 @@ - (void)setCurTopic:(ProjectTopic *)curTopic{
103103
_curTopic = curTopic;
104104
}
105105

106-
CGFloat curBottomY = 10;
107-
CGFloat curWidth = kScreen_Width -2*kPaddingLeftWidth - 50;
106+
CGFloat curBottomY = 0;
107+
CGFloat curWidth = kScreen_Width -2*kPaddingLeftWidth;
108108
[_userIconView sd_setImageWithURL:[_curTopic.owner.avatar urlImageWithCodePathResizeToView:_userIconView] placeholderImage:kPlaceholderMonkeyRoundView(_userIconView)];
109109
[_titleLabel setLongString:_curTopic.title withFitWidth:curWidth];
110-
curBottomY += 15+ [_curTopic.title getHeightWithFont:kTopicContentCell_FontTitle constrainedToSize:CGSizeMake(curWidth, CGFLOAT_MAX)];
110+
curBottomY += CGRectGetMaxY(_titleLabel.frame) + 15;
111111

112112
[_userIconView setY:curBottomY];
113113
[_timeLabel setY:curBottomY];
114-
_timeLabel.text = [NSString stringWithFormat:@"%@ 发布于 %@", _curTopic.owner.name, [_curTopic.created_at stringTimesAgo]];
115-
curBottomY += 10+ 20;
114+
_timeLabel.attributedText = [self getStringWithName:_curTopic.owner.name andTime:[_curTopic.created_at stringTimesAgo]];
115+
116+
curBottomY += 15+ 20;
116117

117118
// 讨论的内容
118119
[self.webContentView setY:curBottomY];
@@ -138,15 +139,26 @@ - (void)setCurTopic:(ProjectTopic *)curTopic{
138139
}
139140
}
140141

142+
- (NSMutableAttributedString*)getStringWithName:(NSString *)nameStr andTime:(NSString *)timeStr{
143+
NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ 发布于 %@", nameStr, timeStr]];
144+
[attriString addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:14],
145+
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x222222"]}
146+
range:NSMakeRange(0, nameStr.length)];
147+
148+
[attriString addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12],
149+
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x999999"]}
150+
range:NSMakeRange(nameStr.length, attriString.length - nameStr.length)];
151+
return attriString;
152+
}
153+
141154
+ (CGFloat)cellHeightWithObj:(id)obj{
142155
CGFloat cellHeight = 0;
143156
if ([obj isKindOfClass:[ProjectTopic class]]) {
144157
ProjectTopic *topic = (ProjectTopic *)obj;
145-
CGFloat curWidth = kScreen_Width -2*kPaddingLeftWidth - 50;
146-
cellHeight += 10 + [topic.title getHeightWithFont:kTopicContentCell_FontTitle constrainedToSize:CGSizeMake(curWidth, CGFLOAT_MAX)] +5 +20 +10;
158+
CGFloat curWidth = kScreen_Width -2*kPaddingLeftWidth;
159+
cellHeight += 15 + [topic.title getHeightWithFont:kTopicContentCell_FontTitle constrainedToSize:CGSizeMake(curWidth, CGFLOAT_MAX)] +15 +20 +15;
147160
cellHeight += topic.contentHeight;
148-
cellHeight += 20+10;
149-
cellHeight += 15;
161+
cellHeight += 5+ 25+ 5;
150162
}
151163
return cellHeight;
152164
}

0 commit comments

Comments
 (0)